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 | 34 | Copyright @copyright{} 2017 Mathieu Othacehe@* |
82ccc499 | 35 | Copyright @copyright{} 2017 Federico Beffa@* |
9260b9d1 TD |
36 | Copyright @copyright{} 2017 Carlo Zancanaro@* |
37 | Copyright @copyright{} 2017 Thomas Danckaert | |
7df7a74e NK |
38 | |
39 | Permission is granted to copy, distribute and/or modify this document | |
40 | under the terms of the GNU Free Documentation License, Version 1.3 or | |
41 | any later version published by the Free Software Foundation; with no | |
42 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A | |
43 | copy of the license is included in the section entitled ``GNU Free | |
44 | Documentation License''. | |
45 | @end copying | |
568717fd | 46 | |
abd67856 | 47 | @dircategory System administration |
568717fd | 48 | @direntry |
abd67856 LC |
49 | * Guix: (guix). Manage installed software and system configuration. |
50 | * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages. | |
abd67856 LC |
51 | * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space. |
52 | * guix pull: (guix)Invoking guix pull. Update the list of available packages. | |
53 | * guix system: (guix)Invoking guix system. Manage the operating system configuration. | |
568717fd | 54 | @end direntry |
568717fd | 55 | |
372c4bbc DT |
56 | @dircategory Software development |
57 | @direntry | |
abd67856 | 58 | * guix environment: (guix)Invoking guix environment. Building development environments with Guix. |
ad172c4a LC |
59 | * guix build: (guix)Invoking guix build. Building packages. |
60 | * guix pack: (guix)Invoking guix pack. Creating binary bundles. | |
372c4bbc DT |
61 | @end direntry |
62 | ||
568717fd | 63 | @titlepage |
7730d112 LC |
64 | @title GNU Guix Reference Manual |
65 | @subtitle Using the GNU Guix Functional Package Manager | |
2cbed07e | 66 | @author The GNU Guix Developers |
568717fd LC |
67 | |
68 | @page | |
69 | @vskip 0pt plus 1filll | |
70 | Edition @value{EDITION} @* | |
71 | @value{UPDATED} @* | |
72 | ||
7df7a74e | 73 | @insertcopying |
568717fd LC |
74 | @end titlepage |
75 | ||
568717fd LC |
76 | @contents |
77 | ||
78 | @c ********************************************************************* | |
79 | @node Top | |
f8348b91 | 80 | @top GNU Guix |
568717fd | 81 | |
f8348b91 LC |
82 | This document describes GNU Guix version @value{VERSION}, a functional |
83 | package management tool written for the GNU system. | |
568717fd LC |
84 | |
85 | @menu | |
86 | * Introduction:: What is Guix about? | |
bd5e766b | 87 | * Installation:: Installing Guix. |
eeaf4427 | 88 | * Package Management:: Package installation, upgrade, etc. |
568717fd LC |
89 | * Programming Interface:: Using Guix in Scheme. |
90 | * Utilities:: Package management commands. | |
a1ba8475 | 91 | * GNU Distribution:: Software for your friendly GNU system. |
9bf3c1a7 | 92 | * Contributing:: Your help needed! |
568717fd LC |
93 | |
94 | * Acknowledgments:: Thanks! | |
95 | * GNU Free Documentation License:: The license of this manual. | |
96 | * Concept Index:: Concepts. | |
a85b83d2 | 97 | * Programming Index:: Data types, functions, and variables. |
aaa3eaa9 LC |
98 | |
99 | @detailmenu | |
100 | --- The Detailed Node Listing --- | |
101 | ||
102 | Installation | |
103 | ||
1b2b8177 | 104 | * Binary Installation:: Getting Guix running in no time! |
aaa3eaa9 | 105 | * Requirements:: Software needed to build and run Guix. |
ec0339cd | 106 | * Running the Test Suite:: Testing Guix. |
aaa3eaa9 LC |
107 | * Setting Up the Daemon:: Preparing the build daemon's environment. |
108 | * Invoking guix-daemon:: Running the build daemon. | |
0e2d0213 | 109 | * Application Setup:: Application-specific setup. |
aaa3eaa9 LC |
110 | |
111 | Setting Up the Daemon | |
112 | ||
113 | * Build Environment Setup:: Preparing the isolated build environment. | |
114 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
115 | ||
116 | Package Management | |
117 | ||
118 | * Features:: How Guix will make your life brighter. | |
119 | * Invoking guix package:: Package installation, removal, etc. | |
aaa3eaa9 LC |
120 | * Substitutes:: Downloading pre-built binaries. |
121 | * Packages with Multiple Outputs:: Single source package, multiple outputs. | |
122 | * Invoking guix gc:: Running the garbage collector. | |
123 | * Invoking guix pull:: Fetching the latest Guix and distribution. | |
239c2266 | 124 | * Invoking guix pack:: Creating software bundles. |
aaa3eaa9 LC |
125 | * Invoking guix archive:: Exporting and importing store files. |
126 | ||
127 | Programming Interface | |
128 | ||
129 | * Defining Packages:: Defining new packages. | |
130 | * Build Systems:: Specifying how packages are built. | |
131 | * The Store:: Manipulating the package store. | |
132 | * Derivations:: Low-level interface to package derivations. | |
133 | * The Store Monad:: Purely functional interface to the store. | |
134 | * G-Expressions:: Manipulating build expressions. | |
135 | ||
92492b23 LC |
136 | Defining Packages |
137 | ||
138 | * package Reference:: The package data type. | |
139 | * origin Reference:: The origin data type. | |
140 | ||
aaa3eaa9 LC |
141 | Utilities |
142 | ||
143 | * Invoking guix build:: Building packages from the command line. | |
fcc58db6 | 144 | * Invoking guix edit:: Editing package definitions. |
aaa3eaa9 LC |
145 | * Invoking guix download:: Downloading a file and printing its hash. |
146 | * Invoking guix hash:: Computing the cryptographic hash of a file. | |
147 | * Invoking guix import:: Importing package definitions. | |
148 | * Invoking guix refresh:: Updating package definitions. | |
149 | * Invoking guix lint:: Finding errors in package definitions. | |
fcc58db6 | 150 | * Invoking guix size:: Profiling disk usage. |
88856916 | 151 | * Invoking guix graph:: Visualizing the graph of packages. |
aaa3eaa9 | 152 | * Invoking guix environment:: Setting up development environments. |
aff8ce7c | 153 | * Invoking guix publish:: Sharing substitutes. |
d23c20f1 | 154 | * Invoking guix challenge:: Challenging substitute servers. |
f11c444d | 155 | * Invoking guix copy:: Copying to and from a remote store. |
32efa254 | 156 | * Invoking guix container:: Process isolation. |
aaa3eaa9 | 157 | |
e3009f60 LC |
158 | Invoking @command{guix build} |
159 | ||
160 | * Common Build Options:: Build options for most commands. | |
f11c444d | 161 | * Package Transformation Options:: Creating variants of packages. |
e3009f60 LC |
162 | * Additional Build Options:: Options specific to 'guix build'. |
163 | ||
aaa3eaa9 LC |
164 | GNU Distribution |
165 | ||
166 | * System Installation:: Installing the whole operating system. | |
35ed9306 | 167 | * System Configuration:: Configuring the operating system. |
aaa3eaa9 LC |
168 | * Installing Debugging Files:: Feeding the debugger. |
169 | * Security Updates:: Deploying security fixes quickly. | |
170 | * Package Modules:: Packages from the programmer's viewpoint. | |
171 | * Packaging Guidelines:: Growing the distribution. | |
172 | * Bootstrapping:: GNU/Linux built from scratch. | |
173 | * Porting:: Targeting another platform or kernel. | |
174 | ||
e3009f60 LC |
175 | System Installation |
176 | ||
177 | * Limitations:: What you can expect. | |
178 | * Hardware Considerations:: Supported hardware. | |
179 | * USB Stick Installation:: Preparing the installation medium. | |
180 | * Preparing for Installation:: Networking, partitioning, etc. | |
181 | * Proceeding with the Installation:: The real thing. | |
c8b54374 | 182 | * Installing GuixSD in a VM:: GuixSD playground. |
e3009f60 LC |
183 | * Building the Installation Image:: How this comes to be. |
184 | ||
aaa3eaa9 LC |
185 | System Configuration |
186 | ||
187 | * Using the Configuration System:: Customizing your GNU system. | |
188 | * operating-system Reference:: Detail of operating-system declarations. | |
189 | * File Systems:: Configuring file system mounts. | |
190 | * Mapped Devices:: Block device extra processing. | |
191 | * User Accounts:: Specifying user accounts. | |
598e19dc | 192 | * Locales:: Language and cultural convention settings. |
aaa3eaa9 LC |
193 | * Services:: Specifying system services. |
194 | * Setuid Programs:: Programs running with root privileges. | |
1b2b8177 | 195 | * X.509 Certificates:: Authenticating HTTPS servers. |
996ed739 | 196 | * Name Service Switch:: Configuring libc's name service switch. |
aaa3eaa9 LC |
197 | * Initial RAM Disk:: Linux-Libre bootstrapping. |
198 | * GRUB Configuration:: Configuring the boot loader. | |
199 | * Invoking guix system:: Instantiating a system configuration. | |
97d76250 | 200 | * Running GuixSD in a VM:: How to run GuixSD in a virtual machine. |
aaa3eaa9 LC |
201 | * Defining Services:: Adding new service definitions. |
202 | ||
203 | Services | |
204 | ||
205 | * Base Services:: Essential system services. | |
c311089b | 206 | * Scheduled Job Execution:: The mcron service. |
92c03a87 | 207 | * Log Rotation:: The rottlog service. |
aaa3eaa9 LC |
208 | * Networking Services:: Network setup, SSH daemon, etc. |
209 | * X Window:: Graphical display. | |
f11c444d | 210 | * Printing Services:: Local and remote printer support. |
1b2b8177 LC |
211 | * Desktop Services:: D-Bus and desktop services. |
212 | * Database Services:: SQL databases. | |
d8c18af8 | 213 | * Mail Services:: IMAP, POP3, SMTP, and all that. |
78cef99b | 214 | * Messaging Services:: Messaging services. |
859e367d | 215 | * Kerberos Services:: Kerberos services. |
cbd02397 | 216 | * Web Services:: Web servers. |
2be1b471 | 217 | * VPN Services:: VPN daemons. |
eb419bc9 | 218 | * Network File System:: NFS related services. |
f11c444d | 219 | * Continuous Integration:: The Cuirass service. |
bfbf6e1e | 220 | * Power management Services:: The TLP tool. |
dbc6d370 | 221 | * Miscellaneous Services:: Other services. |
aaa3eaa9 | 222 | |
0adfe95a LC |
223 | Defining Services |
224 | ||
225 | * Service Composition:: The model for composing services. | |
226 | * Service Types and Services:: Types and services. | |
227 | * Service Reference:: API reference. | |
dd17bc38 | 228 | * Shepherd Services:: A particular type of service. |
0adfe95a | 229 | |
aaa3eaa9 LC |
230 | Packaging Guidelines |
231 | ||
ec0339cd LC |
232 | * Software Freedom:: What may go into the distribution. |
233 | * Package Naming:: What's in a name? | |
234 | * Version Numbers:: When the name is not enough. | |
cbd02397 | 235 | * Synopses and Descriptions:: Helping users find the right package. |
ec0339cd LC |
236 | * Python Modules:: Taming the snake. |
237 | * Perl Modules:: Little pearls. | |
e1c963bf | 238 | * Java Packages:: Coffee break. |
ec0339cd | 239 | * Fonts:: Fond of fonts. |
aaa3eaa9 | 240 | |
8c01b9d0 ML |
241 | Contributing |
242 | ||
243 | * Building from Git:: The latest and greatest. | |
244 | * Running Guix Before It Is Installed:: Hacker tricks. | |
245 | * The Perfect Setup:: The right tools. | |
246 | * Coding Style:: Hygiene of the contributor. | |
247 | * Submitting Patches:: Share your work. | |
248 | ||
249 | Coding Style | |
250 | ||
251 | * Programming Paradigm:: How to compose your elements. | |
252 | * Modules:: Where to store your code? | |
253 | * Data Types and Pattern Matching:: Implementing data structures. | |
254 | * Formatting Code:: Writing conventions. | |
255 | ||
aaa3eaa9 | 256 | @end detailmenu |
568717fd LC |
257 | @end menu |
258 | ||
259 | @c ********************************************************************* | |
260 | @node Introduction | |
261 | @chapter Introduction | |
262 | ||
6f773606 | 263 | @cindex purpose |
c80e7e55 | 264 | GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks'' |
6f773606 LC |
265 | using the international phonetic alphabet (IPA).} is a package |
266 | management tool for the GNU system. Guix makes it easy for unprivileged | |
267 | users to install, upgrade, or remove packages, to roll back to a | |
268 | previous package set, to build packages from source, and generally | |
269 | assists with the creation and maintenance of software environments. | |
270 | ||
271 | @cindex user interfaces | |
272 | Guix provides a command-line package management interface | |
273 | (@pxref{Invoking guix package}), a set of command-line utilities | |
deb6276d | 274 | (@pxref{Utilities}), as well as Scheme programming interfaces |
6f773606 LC |
275 | (@pxref{Programming Interface}). |
276 | @cindex build daemon | |
277 | Its @dfn{build daemon} is responsible for building packages on behalf of | |
278 | users (@pxref{Setting Up the Daemon}) and for downloading pre-built | |
279 | binaries from authorized sources (@pxref{Substitutes}). | |
280 | ||
281 | @cindex extensibility of the distribution | |
e32171ee | 282 | @cindex customization, of packages |
6f773606 LC |
283 | Guix includes package definitions for many GNU and non-GNU packages, all |
284 | of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the | |
285 | user's computing freedom}. It is @emph{extensible}: users can write | |
286 | their own package definitions (@pxref{Defining Packages}) and make them | |
287 | available as independent package modules (@pxref{Package Modules}). It | |
288 | is also @emph{customizable}: users can @emph{derive} specialized package | |
289 | definitions from existing ones, including from the command line | |
290 | (@pxref{Package Transformation Options}). | |
291 | ||
292 | @cindex Guix System Distribution | |
293 | @cindex GuixSD | |
294 | You can install GNU@tie{}Guix on top of an existing GNU/Linux system | |
295 | where it complements the available tools without interference | |
296 | (@pxref{Installation}), or you can use it as part of the standalone | |
297 | @dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}). | |
298 | With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating | |
299 | system configuration and Guix takes care of instantiating the | |
300 | configuration in a transactional, reproducible, and stateless fashion | |
301 | (@pxref{System Configuration}). | |
568717fd LC |
302 | |
303 | @cindex functional package management | |
6f773606 | 304 | Under the hood, Guix implements the @dfn{functional package management} |
136787cb LC |
305 | discipline pioneered by Nix (@pxref{Acknowledgments}). |
306 | In Guix, the package build and installation process is seen | |
6f773606 | 307 | as a @emph{function}, in the mathematical sense. That function takes inputs, |
4bfc4ea3 NK |
308 | such as build scripts, a compiler, and libraries, and |
309 | returns an installed package. As a pure function, its result depends | |
568717fd LC |
310 | solely on its inputs---for instance, it cannot refer to software or |
311 | scripts that were not explicitly passed as inputs. A build function | |
4bfc4ea3 | 312 | always produces the same result when passed a given set of inputs. It |
f97c9175 | 313 | cannot alter the environment of the running system in |
568717fd LC |
314 | any way; for instance, it cannot create, modify, or delete files outside |
315 | of its build and installation directories. This is achieved by running | |
e900c503 | 316 | build processes in isolated environments (or @dfn{containers}), where only their |
4bfc4ea3 | 317 | explicit inputs are visible. |
568717fd | 318 | |
e531ac2a | 319 | @cindex store |
568717fd | 320 | The result of package build functions is @dfn{cached} in the file |
e531ac2a | 321 | system, in a special directory called @dfn{the store} (@pxref{The |
f97c9175 | 322 | Store}). Each package is installed in a directory of its own in the |
834129e0 | 323 | store---by default under @file{/gnu/store}. The directory name contains |
568717fd LC |
324 | a hash of all the inputs used to build that package; thus, changing an |
325 | input yields a different directory name. | |
326 | ||
f97c9175 AE |
327 | This approach is the foundation for the salient features of Guix: support |
328 | for transactional package upgrade and rollback, per-user installation, and | |
eeaf4427 | 329 | garbage collection of packages (@pxref{Features}). |
568717fd | 330 | |
a1ba8475 | 331 | |
bd5e766b LC |
332 | @c ********************************************************************* |
333 | @node Installation | |
334 | @chapter Installation | |
335 | ||
e32171ee | 336 | @cindex installing Guix |
48febeb8 LC |
337 | GNU Guix is available for download from its website at |
338 | @url{http://www.gnu.org/software/guix/}. This section describes the | |
339 | software requirements of Guix, as well as how to install it and get | |
340 | ready to use it. | |
bd5e766b | 341 | |
5af6de3e LC |
342 | Note that this section is concerned with the installation of the package |
343 | manager, which can be done on top of a running GNU/Linux system. If, | |
344 | instead, you want to install the complete GNU operating system, | |
6621cdb6 | 345 | @pxref{System Installation}. |
5af6de3e | 346 | |
d23ef788 LC |
347 | @cindex foreign distro |
348 | When installed on a running GNU/Linux system---thereafter called a | |
349 | @dfn{foreign distro}---GNU@tie{}Guix complements the available tools | |
350 | without interference. Its data lives exclusively in two directories, | |
351 | usually @file{/gnu/store} and @file{/var/guix}; other files on your | |
352 | system, such as @file{/etc}, are left untouched. | |
353 | ||
7fcf2a0b LC |
354 | Once installed, Guix can be updated by running @command{guix pull} |
355 | (@pxref{Invoking guix pull}). | |
356 | ||
bd5e766b | 357 | @menu |
09722b11 | 358 | * Binary Installation:: Getting Guix running in no time! |
bd5e766b | 359 | * Requirements:: Software needed to build and run Guix. |
ec0339cd | 360 | * Running the Test Suite:: Testing Guix. |
bd5e766b LC |
361 | * Setting Up the Daemon:: Preparing the build daemon's environment. |
362 | * Invoking guix-daemon:: Running the build daemon. | |
0e2d0213 | 363 | * Application Setup:: Application-specific setup. |
bd5e766b LC |
364 | @end menu |
365 | ||
09722b11 LC |
366 | @node Binary Installation |
367 | @section Binary Installation | |
368 | ||
e32171ee | 369 | @cindex installing Guix from binaries |
09722b11 LC |
370 | This section describes how to install Guix on an arbitrary system from a |
371 | self-contained tarball providing binaries for Guix and for all its | |
372 | dependencies. This is often quicker than installing from source, which | |
373 | is described in the next sections. The only requirement is to have | |
374 | GNU@tie{}tar and Xz. | |
375 | ||
376 | Installing goes along these lines: | |
377 | ||
378 | @enumerate | |
379 | @item | |
e32171ee | 380 | @cindex downloading Guix binary |
09722b11 | 381 | Download the binary tarball from |
daa8922a LC |
382 | @indicateurl{ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz}, |
383 | where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine | |
384 | already running the kernel Linux, and so on. | |
385 | ||
debc6360 | 386 | @c The following is somewhat duplicated in ``System Installation''. |
daa8922a LC |
387 | Make sure to download the associated @file{.sig} file and to verify the |
388 | authenticity of the tarball against it, along these lines: | |
389 | ||
390 | @example | |
391 | $ wget ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig | |
392 | $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig | |
393 | @end example | |
394 | ||
f97c9175 | 395 | If that command fails because you do not have the required public key, |
daa8922a LC |
396 | then run this command to import it: |
397 | ||
398 | @example | |
debc6360 | 399 | $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID} |
daa8922a LC |
400 | @end example |
401 | ||
402 | @noindent | |
403 | and rerun the @code{gpg --verify} command. | |
debc6360 | 404 | @c end authentication part |
09722b11 LC |
405 | |
406 | @item | |
407 | As @code{root}, run: | |
408 | ||
409 | @example | |
5dc42964 | 410 | # cd /tmp |
254b1c2e LC |
411 | # tar --warning=no-timestamp -xf \ |
412 | guix-binary-@value{VERSION}.@var{system}.tar.xz | |
5dc42964 | 413 | # mv var/guix /var/ && mv gnu / |
09722b11 LC |
414 | @end example |
415 | ||
7acd3439 LC |
416 | This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}. |
417 | The latter contains a ready-to-use profile for @code{root} (see next | |
418 | step.) | |
09722b11 | 419 | |
5dc3ce5f LC |
420 | Do @emph{not} unpack the tarball on a working Guix system since that |
421 | would overwrite its own essential files. | |
422 | ||
254b1c2e | 423 | The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does |
e9ba6357 LC |
424 | not emit warnings about ``implausibly old time stamps'' (such |
425 | warnings were triggered by GNU@tie{}tar 1.26 and older; recent | |
426 | versions are fine.) | |
427 | They stem from the fact that all the | |
254b1c2e LC |
428 | files in the archive have their modification time set to zero (which |
429 | means January 1st, 1970.) This is done on purpose to make sure the | |
430 | archive content is independent of its creation time, thus making it | |
431 | reproducible. | |
432 | ||
7acd3439 LC |
433 | @item |
434 | Make @code{root}'s profile available under @file{~/.guix-profile}: | |
435 | ||
436 | @example | |
437 | # ln -sf /var/guix/profiles/per-user/root/guix-profile \ | |
438 | ~root/.guix-profile | |
439 | @end example | |
440 | ||
43c33047 LC |
441 | @item |
442 | Create the group and user accounts for build users as explained below | |
443 | (@pxref{Build Environment Setup}). | |
444 | ||
09722b11 | 445 | @item |
bf98aea9 | 446 | Run the daemon, and set it to automatically start on boot. |
c8e26887 | 447 | |
bf98aea9 LC |
448 | If your host distro uses the systemd init system, this can be achieved |
449 | with these commands: | |
c8e26887 | 450 | |
b812da70 LF |
451 | @c Versions of systemd that supported symlinked service files are not |
452 | @c yet widely deployed, so we should suggest that users copy the service | |
453 | @c files into place. | |
454 | @c | |
455 | @c See this thread for more information: | |
456 | @c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html | |
457 | ||
c8e26887 | 458 | @example |
b812da70 | 459 | # cp ~root/.guix-profile/lib/systemd/system/guix-daemon.service \ |
c8e26887 GC |
460 | /etc/systemd/system/ |
461 | # systemctl start guix-daemon && systemctl enable guix-daemon | |
462 | @end example | |
463 | ||
464 | If your host distro uses the Upstart init system: | |
09722b11 LC |
465 | |
466 | @example | |
4a780bdf | 467 | # initctl reload-configuration |
b812da70 | 468 | # cp ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/ |
bf98aea9 | 469 | # start guix-daemon |
09722b11 LC |
470 | @end example |
471 | ||
c8e26887 GC |
472 | Otherwise, you can still start the daemon manually with: |
473 | ||
474 | @example | |
475 | # ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild | |
476 | @end example | |
d2825c96 | 477 | |
09722b11 LC |
478 | @item |
479 | Make the @command{guix} command available to other users on the machine, | |
480 | for instance with: | |
481 | ||
482 | @example | |
483 | # mkdir -p /usr/local/bin | |
484 | # cd /usr/local/bin | |
d72d05f9 | 485 | # ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix |
09722b11 | 486 | @end example |
39f8ed14 | 487 | |
aca738f3 LC |
488 | It is also a good idea to make the Info version of this manual available |
489 | there: | |
490 | ||
491 | @example | |
492 | # mkdir -p /usr/local/share/info | |
493 | # cd /usr/local/share/info | |
494 | # for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ; | |
495 | do ln -s $i ; done | |
496 | @end example | |
497 | ||
498 | That way, assuming @file{/usr/local/share/info} is in the search path, | |
499 | running @command{info guix} will open this manual (@pxref{Other Info | |
500 | Directories,,, texinfo, GNU Texinfo}, for more details on changing the | |
501 | Info search path.) | |
502 | ||
39f8ed14 | 503 | @item |
e32171ee | 504 | @cindex substitutes, authorization thereof |
df061d07 LC |
505 | To use substitutes from @code{hydra.gnu.org} or one of its mirrors |
506 | (@pxref{Substitutes}), authorize them: | |
39f8ed14 LC |
507 | |
508 | @example | |
7acd3439 | 509 | # guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub |
39f8ed14 | 510 | @end example |
7f608a9b LC |
511 | |
512 | @item | |
513 | Each user may need to perform a few additional steps to make their Guix | |
514 | environment ready for use, @pxref{Application Setup}. | |
09722b11 LC |
515 | @end enumerate |
516 | ||
7f608a9b | 517 | Voilà, the installation is complete! |
09722b11 | 518 | |
c8e26887 GC |
519 | You can confirm that Guix is working by installing a sample package into |
520 | the root profile: | |
09722b11 LC |
521 | |
522 | @example | |
c8e26887 | 523 | # guix package -i hello |
09722b11 LC |
524 | @end example |
525 | ||
c8e26887 GC |
526 | The @code{guix} package must remain available in @code{root}'s profile, |
527 | or it would become subject to garbage collection---in which case you | |
528 | would find yourself badly handicapped by the lack of the @command{guix} | |
bf98aea9 LC |
529 | command. In other words, do not remove @code{guix} by running |
530 | @code{guix package -r guix}. | |
531 | ||
532 | The binary installation tarball can be (re)produced and verified simply | |
533 | by running the following command in the Guix source tree: | |
534 | ||
535 | @example | |
536 | make guix-binary.@var{system}.tar.xz | |
537 | @end example | |
c8e26887 | 538 | |
239c2266 LC |
539 | @noindent |
540 | ... which, in turn, runs: | |
541 | ||
542 | @example | |
6b63c43e | 543 | guix pack -s @var{system} --localstatedir guix |
239c2266 LC |
544 | @end example |
545 | ||
546 | @xref{Invoking guix pack}, for more info on this handy tool. | |
09722b11 | 547 | |
bd5e766b LC |
548 | @node Requirements |
549 | @section Requirements | |
550 | ||
09722b11 LC |
551 | This section lists requirements when building Guix from source. The |
552 | build procedure for Guix is the same as for other GNU software, and is | |
553 | not covered here. Please see the files @file{README} and @file{INSTALL} | |
554 | in the Guix source tree for additional details. | |
555 | ||
bd5e766b LC |
556 | GNU Guix depends on the following packages: |
557 | ||
558 | @itemize | |
36626c55 | 559 | @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.9 or |
608e42e7 | 560 | later, including 2.2.x; |
288dca55 | 561 | @item @url{http://gnupg.org/, GNU libgcrypt}; |
1dbe3a8d LC |
562 | @item |
563 | @uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings | |
564 | (@pxref{Guile Preparations, how to install the GnuTLS bindings for | |
565 | Guile,, gnutls-guile, GnuTLS-Guile}); | |
f0b98b84 | 566 | @item @url{http://www.gnu.org/software/make/, GNU Make}. |
8a96bd4b ID |
567 | @end itemize |
568 | ||
569 | The following dependencies are optional: | |
570 | ||
571 | @itemize | |
288dca55 | 572 | @item |
8a96bd4b | 573 | Installing |
288dca55 | 574 | @url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will |
2f7d2d91 LC |
575 | allow you to use the @command{guix import pypi} command (@pxref{Invoking |
576 | guix import}). It is of | |
288dca55 | 577 | interest primarily for developers and not for casual users. |
4591c02e | 578 | |
21531add LC |
579 | @item |
580 | @c Note: We need at least 0.10.2 for 'channel-send-eof'. | |
f11c444d LC |
581 | Support for build offloading (@pxref{Daemon Offload Setup}) and |
582 | @command{guix copy} (@pxref{Invoking guix copy}) depends on | |
21531add LC |
583 | @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH}, |
584 | version 0.10.2 or later. | |
585 | ||
4591c02e LC |
586 | @item |
587 | When @url{http://zlib.net, zlib} is available, @command{guix publish} | |
588 | can compress build byproducts (@pxref{Invoking guix publish}). | |
bd5e766b LC |
589 | @end itemize |
590 | ||
591 | Unless @code{--disable-daemon} was passed to @command{configure}, the | |
592 | following packages are also needed: | |
593 | ||
594 | @itemize | |
368d08f7 LC |
595 | @item @url{http://sqlite.org, SQLite 3}; |
596 | @item @url{http://www.bzip.org, libbz2}; | |
597 | @item @url{http://gcc.gnu.org, GCC's g++}, with support for the | |
598 | C++11 standard. | |
bd5e766b LC |
599 | @end itemize |
600 | ||
e32171ee | 601 | @cindex state directory |
ef5f5c86 LC |
602 | When configuring Guix on a system that already has a Guix installation, |
603 | be sure to specify the same state directory as the existing installation | |
604 | using the @code{--localstatedir} option of the @command{configure} | |
605 | script (@pxref{Directory Variables, @code{localstatedir},, standards, | |
606 | GNU Coding Standards}). The @command{configure} script protects against | |
607 | unintended misconfiguration of @var{localstatedir} so you do not | |
608 | inadvertently corrupt your store (@pxref{The Store}). | |
609 | ||
e32171ee | 610 | @cindex Nix, compatibility |
4bfc4ea3 NK |
611 | When a working installation of @url{http://nixos.org/nix/, the Nix package |
612 | manager} is available, you | |
bd5e766b | 613 | can instead configure Guix with @code{--disable-daemon}. In that case, |
4bfc4ea3 | 614 | Nix replaces the three dependencies above. |
bd5e766b | 615 | |
b22a12fd LC |
616 | Guix is compatible with Nix, so it is possible to share the same store |
617 | between both. To do so, you must pass @command{configure} not only the | |
618 | same @code{--with-store-dir} value, but also the same | |
4bfc4ea3 NK |
619 | @code{--localstatedir} value. The latter is essential because it |
620 | specifies where the database that stores metadata about the store is | |
834129e0 | 621 | located, among other things. The default values for Nix are |
b22a12fd | 622 | @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}. |
4bfc4ea3 NK |
623 | Note that @code{--disable-daemon} is not required if |
624 | your goal is to share the store with Nix. | |
b22a12fd | 625 | |
ec0339cd LC |
626 | @node Running the Test Suite |
627 | @section Running the Test Suite | |
628 | ||
e32171ee | 629 | @cindex test suite |
ec0339cd LC |
630 | After a successful @command{configure} and @code{make} run, it is a good |
631 | idea to run the test suite. It can help catch issues with the setup or | |
632 | environment, or bugs in Guix itself---and really, reporting test | |
633 | failures is a good way to help improve the software. To run the test | |
634 | suite, type: | |
635 | ||
636 | @example | |
637 | make check | |
638 | @end example | |
639 | ||
640 | Test cases can run in parallel: you can use the @code{-j} option of | |
641 | GNU@tie{}make to speed things up. The first run may take a few minutes | |
642 | on a recent machine; subsequent runs will be faster because the store | |
643 | that is created for test purposes will already have various things in | |
644 | cache. | |
645 | ||
a887fd8d LC |
646 | It is also possible to run a subset of the tests by defining the |
647 | @code{TESTS} makefile variable as in this example: | |
648 | ||
649 | @example | |
650 | make check TESTS="tests/store.scm tests/cpio.scm" | |
651 | @end example | |
652 | ||
a9edb211 ML |
653 | By default, tests results are displayed at a file level. In order to |
654 | see the details of every individual test cases, it is possible to define | |
655 | the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example: | |
656 | ||
657 | @example | |
658 | make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no" | |
659 | @end example | |
660 | ||
ec0339cd | 661 | Upon failure, please email @email{bug-guix@@gnu.org} and attach the |
a9edb211 ML |
662 | @file{test-suite.log} file. Please specify the Guix version being used |
663 | as well as version numbers of the dependencies (@pxref{Requirements}) in | |
664 | your message. | |
ec0339cd | 665 | |
0a2f2848 LC |
666 | Guix also comes with a whole-system test suite that tests complete |
667 | GuixSD operating system instances. It can only run on systems where | |
668 | Guix is already installed, using: | |
669 | ||
670 | @example | |
671 | make check-system | |
672 | @end example | |
673 | ||
674 | @noindent | |
675 | or, again, by defining @code{TESTS} to select a subset of tests to run: | |
676 | ||
677 | @example | |
678 | make check-system TESTS="basic mcron" | |
679 | @end example | |
680 | ||
681 | These system tests are defined in the @code{(gnu tests @dots{})} | |
682 | modules. They work by running the operating systems under test with | |
683 | lightweight instrumentation in a virtual machine (VM). They can be | |
684 | computationally intensive or rather cheap, depending on whether | |
685 | substitutes are available for their dependencies (@pxref{Substitutes}). | |
686 | Some of them require a lot of storage space to hold VM images. | |
687 | ||
688 | Again in case of test failures, please send @email{bug-guix@@gnu.org} | |
689 | all the details. | |
690 | ||
bd5e766b LC |
691 | @node Setting Up the Daemon |
692 | @section Setting Up the Daemon | |
693 | ||
694 | @cindex daemon | |
695 | Operations such as building a package or running the garbage collector | |
49e6291a | 696 | are all performed by a specialized process, the @dfn{build daemon}, on |
bd5e766b LC |
697 | behalf of clients. Only the daemon may access the store and its |
698 | associated database. Thus, any operation that manipulates the store | |
699 | goes through the daemon. For instance, command-line tools such as | |
e49951eb | 700 | @command{guix package} and @command{guix build} communicate with the |
bd5e766b LC |
701 | daemon (@i{via} remote procedure calls) to instruct it what to do. |
702 | ||
49e6291a | 703 | The following sections explain how to prepare the build daemon's |
f97c9175 | 704 | environment. See also @ref{Substitutes}, for information on how to allow |
225dafde | 705 | the daemon to download pre-built binaries. |
49e6291a LC |
706 | |
707 | @menu | |
708 | * Build Environment Setup:: Preparing the isolated build environment. | |
709 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
710 | @end menu | |
711 | ||
712 | @node Build Environment Setup | |
713 | @subsection Build Environment Setup | |
714 | ||
e32171ee | 715 | @cindex build environment |
bd5e766b LC |
716 | In a standard multi-user setup, Guix and its daemon---the |
717 | @command{guix-daemon} program---are installed by the system | |
834129e0 | 718 | administrator; @file{/gnu/store} is owned by @code{root} and |
bd5e766b LC |
719 | @command{guix-daemon} runs as @code{root}. Unprivileged users may use |
720 | Guix tools to build packages or otherwise access the store, and the | |
721 | daemon will do it on their behalf, ensuring that the store is kept in a | |
722 | consistent state, and allowing built packages to be shared among users. | |
723 | ||
724 | @cindex build users | |
725 | When @command{guix-daemon} runs as @code{root}, you may not want package | |
726 | build processes themselves to run as @code{root} too, for obvious | |
727 | security reasons. To avoid that, a special pool of @dfn{build users} | |
728 | should be created for use by build processes started by the daemon. | |
729 | These build users need not have a shell and a home directory: they will | |
730 | just be used when the daemon drops @code{root} privileges in build | |
731 | processes. Having several such users allows the daemon to launch | |
732 | distinct build processes under separate UIDs, which guarantees that they | |
733 | do not interfere with each other---an essential feature since builds are | |
734 | regarded as pure functions (@pxref{Introduction}). | |
735 | ||
736 | On a GNU/Linux system, a build user pool may be created like this (using | |
737 | Bash syntax and the @code{shadow} commands): | |
738 | ||
091196b3 LC |
739 | @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html |
740 | @c for why `-G' is needed. | |
bd5e766b | 741 | @example |
cfc149dc LC |
742 | # groupadd --system guixbuild |
743 | # for i in `seq -w 1 10`; | |
bd5e766b | 744 | do |
cfc149dc LC |
745 | useradd -g guixbuild -G guixbuild \ |
746 | -d /var/empty -s `which nologin` \ | |
747 | -c "Guix build user $i" --system \ | |
748 | guixbuilder$i; | |
bd5e766b LC |
749 | done |
750 | @end example | |
751 | ||
752 | @noindent | |
54eb03ab LC |
753 | The number of build users determines how many build jobs may run in |
754 | parallel, as specified by the @option{--max-jobs} option | |
eca69fc0 LC |
755 | (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use |
756 | @command{guix system vm} and related commands, you may need to add the | |
757 | build users to the @code{kvm} group so they can access @file{/dev/kvm}, | |
758 | using @code{-G guixbuild,kvm} instead of @code{-G guixbuild} | |
759 | (@pxref{Invoking guix system}). | |
760 | ||
761 | The @code{guix-daemon} program may then be run as @code{root} with the | |
d2825c96 LC |
762 | following command@footnote{If your machine uses the systemd init system, |
763 | dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service} | |
764 | file in @file{/etc/systemd/system} will ensure that | |
ad227484 MDRS |
765 | @command{guix-daemon} is automatically started. Similarly, if your |
766 | machine uses the Upstart init system, drop the | |
767 | @file{@var{prefix}/lib/upstart/system/guix-daemon.conf} | |
768 | file in @file{/etc/init}.}: | |
bd5e766b LC |
769 | |
770 | @example | |
cfc149dc | 771 | # guix-daemon --build-users-group=guixbuild |
bd5e766b LC |
772 | @end example |
773 | ||
e900c503 | 774 | @cindex chroot |
b095792f LC |
775 | @noindent |
776 | This way, the daemon starts build processes in a chroot, under one of | |
cfc149dc | 777 | the @code{guixbuilder} users. On GNU/Linux, by default, the chroot |
6dc99317 LC |
778 | environment contains nothing but: |
779 | ||
780 | @c Keep this list in sync with libstore/build.cc! ----------------------- | |
781 | @itemize | |
782 | @item | |
4743a4da LC |
783 | a minimal @code{/dev} directory, created mostly independently from the |
784 | host @code{/dev}@footnote{``Mostly'', because while the set of files | |
785 | that appear in the chroot's @code{/dev} is fixed, most of these files | |
786 | can only be created if the host has them.}; | |
787 | ||
788 | @item | |
f97c9175 | 789 | the @code{/proc} directory; it only shows the processes of the container |
4743a4da | 790 | since a separate PID name space is used; |
6dc99317 LC |
791 | |
792 | @item | |
793 | @file{/etc/passwd} with an entry for the current user and an entry for | |
794 | user @file{nobody}; | |
795 | ||
796 | @item | |
797 | @file{/etc/group} with an entry for the user's group; | |
798 | ||
799 | @item | |
800 | @file{/etc/hosts} with an entry that maps @code{localhost} to | |
801 | @code{127.0.0.1}; | |
802 | ||
803 | @item | |
804 | a writable @file{/tmp} directory. | |
805 | @end itemize | |
b095792f | 806 | |
cb960102 ED |
807 | You can influence the directory where the daemon stores build trees |
808 | @i{via} the @code{TMPDIR} environment variable. However, the build tree | |
f97c9175 | 809 | within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0}, |
cb960102 ED |
810 | where @var{name} is the derivation name---e.g., @code{coreutils-8.24}. |
811 | This way, the value of @code{TMPDIR} does not leak inside build | |
812 | environments, which avoids discrepancies in cases where build processes | |
813 | capture the name of their build tree. | |
814 | ||
e0c941fe LC |
815 | @vindex http_proxy |
816 | The daemon also honors the @code{http_proxy} environment variable for | |
817 | HTTP downloads it performs, be it for fixed-output derivations | |
818 | (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}). | |
819 | ||
1e2644bb LC |
820 | If you are installing Guix as an unprivileged user, it is still possible |
821 | to run @command{guix-daemon} provided you pass @code{--disable-chroot}. | |
822 | However, build processes will not be isolated from one another, and not | |
823 | from the rest of the system. Thus, build processes may interfere with | |
824 | each other, and may access programs, libraries, and other files | |
825 | available on the system---making it much harder to view them as | |
826 | @emph{pure} functions. | |
bd5e766b | 827 | |
49e6291a LC |
828 | |
829 | @node Daemon Offload Setup | |
830 | @subsection Using the Offload Facility | |
831 | ||
832 | @cindex offloading | |
4ec2e92d | 833 | @cindex build hook |
21531add LC |
834 | When desired, the build daemon can @dfn{offload} derivation builds to |
835 | other machines running Guix, using the @code{offload} @dfn{build | |
836 | hook}@footnote{This feature is available only when | |
837 | @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is | |
838 | present.}. When that | |
49e6291a | 839 | feature is enabled, a list of user-specified build machines is read from |
f97c9175 | 840 | @file{/etc/guix/machines.scm}; every time a build is requested, for |
49e6291a | 841 | instance via @code{guix build}, the daemon attempts to offload it to one |
f97c9175 | 842 | of the machines that satisfy the constraints of the derivation, in |
49e6291a LC |
843 | particular its system type---e.g., @file{x86_64-linux}. Missing |
844 | prerequisites for the build are copied over SSH to the target machine, | |
845 | which then proceeds with the build; upon success the output(s) of the | |
846 | build are copied back to the initial machine. | |
847 | ||
4ec2e92d | 848 | The @file{/etc/guix/machines.scm} file typically looks like this: |
49e6291a LC |
849 | |
850 | @example | |
851 | (list (build-machine | |
852 | (name "eightysix.example.org") | |
853 | (system "x86_64-linux") | |
21531add | 854 | (host-key "ssh-ed25519 AAAAC3Nza@dots{}") |
49e6291a | 855 | (user "bob") |
21531add | 856 | (speed 2.)) ;incredibly fast! |
49e6291a LC |
857 | |
858 | (build-machine | |
859 | (name "meeps.example.org") | |
860 | (system "mips64el-linux") | |
21531add | 861 | (host-key "ssh-rsa AAAAB3Nza@dots{}") |
49e6291a LC |
862 | (user "alice") |
863 | (private-key | |
864 | (string-append (getenv "HOME") | |
21531add | 865 | "/.ssh/identity-for-guix")))) |
49e6291a LC |
866 | @end example |
867 | ||
868 | @noindent | |
869 | In the example above we specify a list of two build machines, one for | |
870 | the @code{x86_64} architecture and one for the @code{mips64el} | |
4ec2e92d LC |
871 | architecture. |
872 | ||
873 | In fact, this file is---not surprisingly!---a Scheme file that is | |
874 | evaluated when the @code{offload} hook is started. Its return value | |
875 | must be a list of @code{build-machine} objects. While this example | |
876 | shows a fixed list of build machines, one could imagine, say, using | |
877 | DNS-SD to return a list of potential build machines discovered in the | |
878 | local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using | |
c678a4ee LC |
879 | Avahi in Guile Scheme Programs}). The @code{build-machine} data type is |
880 | detailed below. | |
4ec2e92d | 881 | |
c678a4ee | 882 | @deftp {Data Type} build-machine |
f97c9175 AE |
883 | This data type represents build machines to which the daemon may offload |
884 | builds. The important fields are: | |
49e6291a LC |
885 | |
886 | @table @code | |
887 | ||
888 | @item name | |
f97c9175 | 889 | The host name of the remote machine. |
49e6291a LC |
890 | |
891 | @item system | |
f97c9175 | 892 | The system type of the remote machine---e.g., @code{"x86_64-linux"}. |
49e6291a LC |
893 | |
894 | @item user | |
895 | The user account to use when connecting to the remote machine over SSH. | |
896 | Note that the SSH key pair must @emph{not} be passphrase-protected, to | |
897 | allow non-interactive logins. | |
898 | ||
21531add LC |
899 | @item host-key |
900 | This must be the machine's SSH @dfn{public host key} in OpenSSH format. | |
901 | This is used to authenticate the machine when we connect to it. It is a | |
902 | long string that looks like this: | |
903 | ||
904 | @example | |
905 | ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org | |
906 | @end example | |
907 | ||
908 | If the machine is running the OpenSSH daemon, @command{sshd}, the host | |
909 | key can be found in a file such as | |
910 | @file{/etc/ssh/ssh_host_ed25519_key.pub}. | |
911 | ||
912 | If the machine is running the SSH daemon of GNU@tie{}lsh, | |
913 | @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a | |
914 | similar file. It can be converted to the OpenSSH format using | |
915 | @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}): | |
916 | ||
917 | @example | |
918 | $ lsh-export-key --openssh < /etc/lsh/host-key.pub | |
919 | ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{} | |
920 | @end example | |
921 | ||
49e6291a LC |
922 | @end table |
923 | ||
4ec2e92d | 924 | A number of optional fields may be specified: |
49e6291a | 925 | |
21531add | 926 | @table @asis |
49e6291a | 927 | |
21531add LC |
928 | @item @code{port} (default: @code{22}) |
929 | Port number of SSH server on the machine. | |
cecd72d5 | 930 | |
21531add LC |
931 | @item @code{private-key} (default: @file{~/.ssh/id_rsa}) |
932 | The SSH private key file to use when connecting to the machine, in | |
933 | OpenSSH format. | |
49e6291a | 934 | |
1d48cf94 LC |
935 | @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"}) |
936 | @itemx @code{compression-level} (default: @code{3}) | |
937 | The SSH-level compression methods and compression level requested. | |
938 | ||
939 | Note that offloading relies on SSH compression to reduce bandwidth usage | |
940 | when transferring files to and from build machines. | |
941 | ||
cf283dd9 LC |
942 | @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"}) |
943 | File name of the Unix-domain socket @command{guix-daemon} is listening | |
944 | to on that machine. | |
c4fdfd6f | 945 | |
21531add LC |
946 | @item @code{parallel-builds} (default: @code{1}) |
947 | The number of builds that may run in parallel on the machine. | |
49e6291a | 948 | |
21531add | 949 | @item @code{speed} (default: @code{1.0}) |
49e6291a LC |
950 | A ``relative speed factor''. The offload scheduler will tend to prefer |
951 | machines with a higher speed factor. | |
952 | ||
21531add | 953 | @item @code{features} (default: @code{'()}) |
49e6291a LC |
954 | A list of strings denoting specific features supported by the machine. |
955 | An example is @code{"kvm"} for machines that have the KVM Linux modules | |
956 | and corresponding hardware support. Derivations can request features by | |
957 | name, and they will be scheduled on matching build machines. | |
958 | ||
959 | @end table | |
c678a4ee | 960 | @end deftp |
49e6291a | 961 | |
aebaee95 LC |
962 | The @code{guile} command must be in the search path on the build |
963 | machines. In addition, the Guix modules must be in | |
c4fdfd6f LC |
964 | @code{$GUILE_LOAD_PATH} on the build machine---you can check whether |
965 | this is the case by running: | |
966 | ||
967 | @example | |
21531add | 968 | ssh build-machine guile -c "'(use-modules (guix config))'" |
c4fdfd6f | 969 | @end example |
49e6291a | 970 | |
f97c9175 | 971 | There is one last thing to do once @file{machines.scm} is in place. As |
49e6291a | 972 | explained above, when offloading, files are transferred back and forth |
c4fdfd6f LC |
973 | between the machine stores. For this to work, you first need to |
974 | generate a key pair on each machine to allow the daemon to export signed | |
975 | archives of files from the store (@pxref{Invoking guix archive}): | |
49e6291a LC |
976 | |
977 | @example | |
978 | # guix archive --generate-key | |
979 | @end example | |
980 | ||
981 | @noindent | |
c4fdfd6f LC |
982 | Each build machine must authorize the key of the master machine so that |
983 | it accepts store items it receives from the master: | |
984 | ||
985 | @example | |
986 | # guix archive --authorize < master-public-key.txt | |
987 | @end example | |
988 | ||
989 | @noindent | |
990 | Likewise, the master machine must authorize the key of each build machine. | |
991 | ||
992 | All the fuss with keys is here to express pairwise mutual trust | |
993 | relations between the master and the build machines. Concretely, when | |
994 | the master receives files from a build machine (and @i{vice versa}), its | |
995 | build daemon can make sure they are genuine, have not been tampered | |
996 | with, and that they are signed by an authorized key. | |
49e6291a | 997 | |
aebaee95 LC |
998 | @cindex offload test |
999 | To test whether your setup is operational, run this command on the | |
1000 | master node: | |
1001 | ||
1002 | @example | |
1003 | # guix offload test | |
1004 | @end example | |
1005 | ||
1006 | This will attempt to connect to each of the build machines specified in | |
1007 | @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are | |
1008 | available on each machine, attempt to export to the machine and import | |
1009 | from it, and report any error in the process. | |
1010 | ||
1011 | If you want to test a different machine file, just specify it on the | |
1012 | command line: | |
1013 | ||
1014 | @example | |
1015 | # guix offload test machines-qualif.scm | |
1016 | @end example | |
1017 | ||
27991c97 LC |
1018 | Last, you can test the subset of the machines whose name matches a |
1019 | regular expression like this: | |
1020 | ||
1021 | @example | |
1022 | # guix offload test machines.scm '\.gnu\.org$' | |
1023 | @end example | |
49e6291a | 1024 | |
bd5e766b LC |
1025 | @node Invoking guix-daemon |
1026 | @section Invoking @command{guix-daemon} | |
1027 | ||
1028 | The @command{guix-daemon} program implements all the functionality to | |
1029 | access the store. This includes launching build processes, running the | |
1030 | garbage collector, querying the availability of a build result, etc. It | |
1031 | is normally run as @code{root} like this: | |
1032 | ||
1033 | @example | |
cfc149dc | 1034 | # guix-daemon --build-users-group=guixbuild |
bd5e766b LC |
1035 | @end example |
1036 | ||
1037 | @noindent | |
081145cf | 1038 | For details on how to set it up, @pxref{Setting Up the Daemon}. |
bd5e766b | 1039 | |
e900c503 LC |
1040 | @cindex chroot |
1041 | @cindex container, build environment | |
1042 | @cindex build environment | |
1043 | @cindex reproducible builds | |
bd5e766b LC |
1044 | By default, @command{guix-daemon} launches build processes under |
1045 | different UIDs, taken from the build group specified with | |
1046 | @code{--build-users-group}. In addition, each build process is run in a | |
1047 | chroot environment that only contains the subset of the store that the | |
1048 | build process depends on, as specified by its derivation | |
1049 | (@pxref{Programming Interface, derivation}), plus a set of specific | |
1050 | system directories. By default, the latter contains @file{/dev} and | |
e900c503 LC |
1051 | @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a |
1052 | @dfn{container}: in addition to having its own file system tree, it has | |
1053 | a separate mount name space, its own PID name space, network name space, | |
1054 | etc. This helps achieve reproducible builds (@pxref{Features}). | |
bd5e766b | 1055 | |
cbc538fe LC |
1056 | When the daemon performs a build on behalf of the user, it creates a |
1057 | build directory under @file{/tmp} or under the directory specified by | |
1058 | its @code{TMPDIR} environment variable; this directory is shared with | |
1059 | the container for the duration of the build. Be aware that using a | |
1060 | directory other than @file{/tmp} can affect build results---for example, | |
1061 | with a longer directory name, a build process that uses Unix-domain | |
1062 | sockets might hit the name length limitation for @code{sun_path}, which | |
1063 | it would otherwise not hit. | |
1064 | ||
1065 | The build directory is automatically deleted upon completion, unless the | |
1066 | build failed and the client specified @option{--keep-failed} | |
1067 | (@pxref{Invoking guix build, @option{--keep-failed}}). | |
1068 | ||
bd5e766b LC |
1069 | The following command-line options are supported: |
1070 | ||
1071 | @table @code | |
1072 | @item --build-users-group=@var{group} | |
1073 | Take users from @var{group} to run build processes (@pxref{Setting Up | |
1074 | the Daemon, build users}). | |
1075 | ||
6858f9d1 | 1076 | @item --no-substitutes |
b5385b52 | 1077 | @cindex substitutes |
6858f9d1 | 1078 | Do not use substitutes for build products. That is, always build things |
c4202d60 LC |
1079 | locally instead of allowing downloads of pre-built binaries |
1080 | (@pxref{Substitutes}). | |
6858f9d1 | 1081 | |
b5385b52 LC |
1082 | By default substitutes are used, unless the client---such as the |
1083 | @command{guix package} command---is explicitly invoked with | |
1084 | @code{--no-substitutes}. | |
1085 | ||
1086 | When the daemon runs with @code{--no-substitutes}, clients can still | |
1087 | explicitly enable substitution @i{via} the @code{set-build-options} | |
1088 | remote procedure call (@pxref{The Store}). | |
1089 | ||
9176607e | 1090 | @item --substitute-urls=@var{urls} |
f8a8e0fe | 1091 | @anchor{daemon-substitute-urls} |
9176607e | 1092 | Consider @var{urls} the default whitespace-separated list of substitute |
df061d07 LC |
1093 | source URLs. When this option is omitted, |
1094 | @indicateurl{https://mirror.hydra.gnu.org https://hydra.gnu.org} is used | |
1095 | (@code{mirror.hydra.gnu.org} is a mirror of @code{hydra.gnu.org}). | |
9176607e LC |
1096 | |
1097 | This means that substitutes may be downloaded from @var{urls}, as long | |
1098 | as they are signed by a trusted signature (@pxref{Substitutes}). | |
1099 | ||
4ec2e92d LC |
1100 | @cindex build hook |
1101 | @item --no-build-hook | |
1102 | Do not use the @dfn{build hook}. | |
1103 | ||
1104 | The build hook is a helper program that the daemon can start and to | |
1105 | which it submits build requests. This mechanism is used to offload | |
1106 | builds to other machines (@pxref{Daemon Offload Setup}). | |
1107 | ||
bd5e766b LC |
1108 | @item --cache-failures |
1109 | Cache build failures. By default, only successful builds are cached. | |
1110 | ||
30d9aa54 LC |
1111 | When this option is used, @command{guix gc --list-failures} can be used |
1112 | to query the set of store items marked as failed; @command{guix gc | |
1113 | --clear-failures} removes store items from the set of cached failures. | |
1114 | @xref{Invoking guix gc}. | |
1115 | ||
bd5e766b LC |
1116 | @item --cores=@var{n} |
1117 | @itemx -c @var{n} | |
1118 | Use @var{n} CPU cores to build each derivation; @code{0} means as many | |
1119 | as available. | |
1120 | ||
6efc160e | 1121 | The default value is @code{0}, but it may be overridden by clients, such |
e49951eb MW |
1122 | as the @code{--cores} option of @command{guix build} (@pxref{Invoking |
1123 | guix build}). | |
bd5e766b LC |
1124 | |
1125 | The effect is to define the @code{NIX_BUILD_CORES} environment variable | |
1126 | in the build process, which can then use it to exploit internal | |
1127 | parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}. | |
1128 | ||
1129 | @item --max-jobs=@var{n} | |
1130 | @itemx -M @var{n} | |
1131 | Allow at most @var{n} build jobs in parallel. The default value is | |
f6526eb3 LC |
1132 | @code{1}. Setting it to @code{0} means that no builds will be performed |
1133 | locally; instead, the daemon will offload builds (@pxref{Daemon Offload | |
1134 | Setup}), or simply fail. | |
bd5e766b | 1135 | |
ecf84b7c LC |
1136 | @item --rounds=@var{N} |
1137 | Build each derivation @var{n} times in a row, and raise an error if | |
1138 | consecutive build results are not bit-for-bit identical. Note that this | |
1139 | setting can be overridden by clients such as @command{guix build} | |
1140 | (@pxref{Invoking guix build}). | |
1141 | ||
b4528110 ED |
1142 | When used in conjunction with @option{--keep-failed}, the differing |
1143 | output is kept in the store, under @file{/gnu/store/@dots{}-check}. | |
1144 | This makes it easy to look for differences between the two results. | |
1145 | ||
bd5e766b LC |
1146 | @item --debug |
1147 | Produce debugging output. | |
1148 | ||
1149 | This is useful to debug daemon start-up issues, but then it may be | |
1150 | overridden by clients, for example the @code{--verbosity} option of | |
e49951eb | 1151 | @command{guix build} (@pxref{Invoking guix build}). |
bd5e766b LC |
1152 | |
1153 | @item --chroot-directory=@var{dir} | |
1154 | Add @var{dir} to the build chroot. | |
1155 | ||
1156 | Doing this may change the result of build processes---for instance if | |
1157 | they use optional dependencies found in @var{dir} when it is available, | |
1158 | and not otherwise. For that reason, it is not recommended to do so. | |
1159 | Instead, make sure that each derivation declares all the inputs that it | |
1160 | needs. | |
1161 | ||
1162 | @item --disable-chroot | |
1163 | Disable chroot builds. | |
1164 | ||
1165 | Using this option is not recommended since, again, it would allow build | |
1e2644bb LC |
1166 | processes to gain access to undeclared dependencies. It is necessary, |
1167 | though, when @command{guix-daemon} is running under an unprivileged user | |
1168 | account. | |
bd5e766b LC |
1169 | |
1170 | @item --disable-log-compression | |
1171 | Disable compression of the build logs. | |
1172 | ||
1da983b9 LC |
1173 | Unless @code{--lose-logs} is used, all the build logs are kept in the |
1174 | @var{localstatedir}. To save space, the daemon automatically compresses | |
1175 | them with bzip2 by default. This option disables that. | |
1176 | ||
ab3893d7 LC |
1177 | @item --disable-deduplication |
1178 | @cindex deduplication | |
bd5e766b LC |
1179 | Disable automatic file ``deduplication'' in the store. |
1180 | ||
1da983b9 | 1181 | By default, files added to the store are automatically ``deduplicated'': |
ab3893d7 LC |
1182 | if a newly added file is identical to another one found in the store, |
1183 | the daemon makes the new file a hard link to the other file. This can | |
4988dd40 | 1184 | noticeably reduce disk usage, at the expense of slightly increased |
ab3893d7 LC |
1185 | input/output load at the end of a build process. This option disables |
1186 | this optimization. | |
1da983b9 | 1187 | |
6e37066e LC |
1188 | @item --gc-keep-outputs[=yes|no] |
1189 | Tell whether the garbage collector (GC) must keep outputs of live | |
1190 | derivations. | |
1191 | ||
1192 | When set to ``yes'', the GC will keep the outputs of any live derivation | |
1193 | available in the store---the @code{.drv} files. The default is ``no'', | |
1194 | meaning that derivation outputs are kept only if they are GC roots. | |
1195 | ||
1196 | @item --gc-keep-derivations[=yes|no] | |
1197 | Tell whether the garbage collector (GC) must keep derivations | |
1198 | corresponding to live outputs. | |
1199 | ||
1200 | When set to ``yes'', as is the case by default, the GC keeps | |
1201 | derivations---i.e., @code{.drv} files---as long as at least one of their | |
1202 | outputs is live. This allows users to keep track of the origins of | |
1203 | items in their store. Setting it to ``no'' saves a bit of disk space. | |
1204 | ||
1205 | Note that when both @code{--gc-keep-derivations} and | |
1206 | @code{--gc-keep-outputs} are used, the effect is to keep all the build | |
1207 | prerequisites (the sources, compiler, libraries, and other build-time | |
1208 | tools) of live objects in the store, regardless of whether these | |
1209 | prerequisites are live. This is convenient for developers since it | |
1210 | saves rebuilds or downloads. | |
1211 | ||
bd5e766b LC |
1212 | @item --impersonate-linux-2.6 |
1213 | On Linux-based systems, impersonate Linux 2.6. This means that the | |
1214 | kernel's @code{uname} system call will report 2.6 as the release number. | |
1215 | ||
1216 | This might be helpful to build programs that (usually wrongfully) depend | |
1217 | on the kernel version number. | |
1218 | ||
1219 | @item --lose-logs | |
1220 | Do not keep build logs. By default they are kept under | |
ce33631f | 1221 | @code{@var{localstatedir}/guix/log}. |
bd5e766b LC |
1222 | |
1223 | @item --system=@var{system} | |
1224 | Assume @var{system} as the current system type. By default it is the | |
1225 | architecture/kernel pair found at configure time, such as | |
1226 | @code{x86_64-linux}. | |
b8d2aa26 LC |
1227 | |
1228 | @item --listen=@var{socket} | |
1229 | Listen for connections on @var{socket}, the file name of a Unix-domain | |
1230 | socket. The default socket is | |
1231 | @file{@var{localstatedir}/daemon-socket/socket}. This option is only | |
1232 | useful in exceptional circumstances, such as if you need to run several | |
1233 | daemons on the same machine. | |
bd5e766b LC |
1234 | @end table |
1235 | ||
1236 | ||
0e2d0213 LC |
1237 | @node Application Setup |
1238 | @section Application Setup | |
1239 | ||
d23ef788 | 1240 | @cindex foreign distro |
85e57214 LC |
1241 | When using Guix on top of GNU/Linux distribution other than GuixSD---a |
1242 | so-called @dfn{foreign distro}---a few additional steps are needed to | |
1243 | get everything in place. Here are some of them. | |
0e2d0213 LC |
1244 | |
1245 | @subsection Locales | |
1246 | ||
5c3c1427 | 1247 | @anchor{locales-and-locpath} |
0e2d0213 | 1248 | @cindex locales, when not on GuixSD |
5c3c1427 | 1249 | @vindex LOCPATH |
85e57214 | 1250 | @vindex GUIX_LOCPATH |
f97c9175 AE |
1251 | Packages installed @i{via} Guix will not use the locale data of the |
1252 | host system. Instead, you must first install one of the locale packages | |
85e57214 LC |
1253 | available with Guix and then define the @code{GUIX_LOCPATH} environment |
1254 | variable: | |
0e2d0213 LC |
1255 | |
1256 | @example | |
1257 | $ guix package -i glibc-locales | |
85e57214 | 1258 | $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale |
0e2d0213 LC |
1259 | @end example |
1260 | ||
1261 | Note that the @code{glibc-locales} package contains data for all the | |
1262 | locales supported by the GNU@tie{}libc and weighs in at around | |
f97c9175 | 1263 | 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but |
0e2d0213 LC |
1264 | limited to a few UTF-8 locales. |
1265 | ||
85e57214 LC |
1266 | The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH} |
1267 | (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference | |
1268 | Manual}). There are two important differences though: | |
1269 | ||
1270 | @enumerate | |
1271 | @item | |
f97c9175 | 1272 | @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc |
85e57214 | 1273 | provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you |
f97c9175 | 1274 | to make sure the programs of the foreign distro will not end up loading |
85e57214 LC |
1275 | incompatible locale data. |
1276 | ||
1277 | @item | |
1278 | libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where | |
1279 | @code{X.Y} is the libc version---e.g., @code{2.22}. This means that, | |
1280 | should your Guix profile contain a mixture of programs linked against | |
1281 | different libc version, each libc version will only try to load locale | |
1282 | data in the right format. | |
1283 | @end enumerate | |
1284 | ||
1285 | This is important because the locale data format used by different libc | |
1286 | versions may be incompatible. | |
1287 | ||
9a5187b6 LC |
1288 | @subsection Name Service Switch |
1289 | ||
1290 | @cindex name service switch, glibc | |
1291 | @cindex NSS (name service switch), glibc | |
1292 | @cindex nscd (name service caching daemon) | |
1293 | @cindex name service caching daemon (nscd) | |
1294 | When using Guix on a foreign distro, we @emph{strongly recommend} that | |
1295 | the system run the GNU C library's @dfn{name service cache daemon}, | |
1296 | @command{nscd}, which should be listening on the | |
1297 | @file{/var/run/nscd/socket} socket. Failing to do that, applications | |
1298 | installed with Guix may fail to look up host names or user accounts, or | |
1299 | may even crash. The next paragraphs explain why. | |
1300 | ||
1301 | @cindex @file{nsswitch.conf} | |
1302 | The GNU C library implements a @dfn{name service switch} (NSS), which is | |
1303 | an extensible mechanism for ``name lookups'' in general: host name | |
1304 | resolution, user accounts, and more (@pxref{Name Service Switch,,, libc, | |
1305 | The GNU C Library Reference Manual}). | |
1306 | ||
1307 | @cindex Network information service (NIS) | |
1308 | @cindex NIS (Network information service) | |
1309 | Being extensible, the NSS supports @dfn{plugins}, which provide new name | |
1310 | lookup implementations: for example, the @code{nss-mdns} plugin allow | |
1311 | resolution of @code{.local} host names, the @code{nis} plugin allows | |
1312 | user account lookup using the Network information service (NIS), and so | |
1313 | on. These extra ``lookup services'' are configured system-wide in | |
1314 | @file{/etc/nsswitch.conf}, and all the programs running on the system | |
1315 | honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C | |
1316 | Reference Manual}). | |
1317 | ||
1318 | When they perform a name lookup---for instance by calling the | |
1319 | @code{getaddrinfo} function in C---applications first try to connect to | |
1320 | the nscd; on success, nscd performs name lookups on their behalf. If | |
1321 | the nscd is not running, then they perform the name lookup by | |
1322 | themselves, by loading the name lookup services into their own address | |
1323 | space and running it. These name lookup services---the | |
1324 | @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from | |
1325 | the host system's C library, rather than from the C library the | |
1326 | application is linked against (the C library coming from Guix). | |
1327 | ||
1328 | And this is where the problem is: if your application is linked against | |
1329 | Guix's C library (say, glibc 2.24) and tries to load NSS plugins from | |
1330 | another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will | |
1331 | likely crash or have its name lookups fail unexpectedly. | |
1332 | ||
1333 | Running @command{nscd} on the system, among other advantages, eliminates | |
1334 | this binary incompatibility problem because those @code{libnss_*.so} | |
1335 | files are loaded in the @command{nscd} process, not in applications | |
1336 | themselves. | |
1337 | ||
0e2d0213 LC |
1338 | @subsection X11 Fonts |
1339 | ||
e32171ee | 1340 | @cindex fonts |
4988dd40 | 1341 | The majority of graphical applications use Fontconfig to locate and |
f97c9175 AE |
1342 | load fonts and perform X11-client-side rendering. The @code{fontconfig} |
1343 | package in Guix looks for fonts in @file{$HOME/.guix-profile} | |
0e2d0213 | 1344 | by default. Thus, to allow graphical applications installed with Guix |
f97c9175 | 1345 | to display fonts, you have to install fonts with Guix as well. |
0e2d0213 | 1346 | Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and |
8fe5b1d1 | 1347 | @code{font-gnu-freefont-ttf}. |
0e2d0213 | 1348 | |
5c36edc8 LC |
1349 | To display text written in Chinese languages, Japanese, or Korean in |
1350 | graphical applications, consider installing | |
1351 | @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former | |
1352 | has multiple outputs, one per language family (@pxref{Packages with | |
1353 | Multiple Outputs}). For instance, the following command installs fonts | |
1354 | for Chinese languages: | |
1355 | ||
1356 | @example | |
1357 | guix package -i font-adobe-source-han-sans:cn | |
1358 | @end example | |
1359 | ||
e32171ee | 1360 | @cindex @code{xterm} |
1a3e6b15 AK |
1361 | Older programs such as @command{xterm} do not use Fontconfig and instead |
1362 | rely on server-side font rendering. Such programs require to specify a | |
1363 | full name of a font using XLFD (X Logical Font Description), like this: | |
1364 | ||
1365 | @example | |
1366 | -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1 | |
1367 | @end example | |
1368 | ||
1369 | To be able to use such full names for the TrueType fonts installed in | |
1370 | your Guix profile, you need to extend the font path of the X server: | |
1371 | ||
1372 | @example | |
1373 | xset +fp ~/.guix-profile/share/fonts/truetype | |
1374 | @end example | |
1375 | ||
e32171ee | 1376 | @cindex @code{xlsfonts} |
1a3e6b15 AK |
1377 | After that, you can run @code{xlsfonts} (from @code{xlsfonts} package) |
1378 | to make sure your TrueType fonts are listed there. | |
1379 | ||
b3129f2b LC |
1380 | @subsection X.509 Certificates |
1381 | ||
e32171ee | 1382 | @cindex @code{nss-certs} |
b3129f2b LC |
1383 | The @code{nss-certs} package provides X.509 certificates, which allow |
1384 | programs to authenticate Web servers accessed over HTTPS. | |
1385 | ||
1386 | When using Guix on a foreign distro, you can install this package and | |
1387 | define the relevant environment variables so that packages know where to | |
80d944b7 | 1388 | look for certificates. @xref{X.509 Certificates}, for detailed |
b3129f2b LC |
1389 | information. |
1390 | ||
6d97319c AK |
1391 | @subsection Emacs Packages |
1392 | ||
e32171ee | 1393 | @cindex @code{emacs} |
6d97319c AK |
1394 | When you install Emacs packages with Guix, the elisp files may be placed |
1395 | either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in | |
1396 | sub-directories of | |
1397 | @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter | |
1398 | directory exists because potentially there may exist thousands of Emacs | |
1399 | packages and storing all their files in a single directory may be not | |
1400 | reliable (because of name conflicts). So we think using a separate | |
1401 | directory for each package is a good idea. It is very similar to how | |
1402 | the Emacs package system organizes the file structure (@pxref{Package | |
1403 | Files,,, emacs, The GNU Emacs Manual}). | |
1404 | ||
1405 | By default, Emacs (installed with Guix) ``knows'' where these packages | |
f97c9175 | 1406 | are placed, so you do not need to perform any configuration. If, for |
6d97319c | 1407 | some reason, you want to avoid auto-loading Emacs packages installed |
f97c9175 | 1408 | with Guix, you can do so by running Emacs with @code{--no-site-file} |
6d97319c AK |
1409 | option (@pxref{Init File,,, emacs, The GNU Emacs Manual}). |
1410 | ||
0e2d0213 LC |
1411 | @c TODO What else? |
1412 | ||
eeaf4427 LC |
1413 | @c ********************************************************************* |
1414 | @node Package Management | |
1415 | @chapter Package Management | |
1416 | ||
e32171ee | 1417 | @cindex packages |
f8348b91 | 1418 | The purpose of GNU Guix is to allow users to easily install, upgrade, and |
eeaf4427 | 1419 | remove software packages, without having to know about their build |
f97c9175 | 1420 | procedures or dependencies. Guix also goes beyond this obvious set of |
eeaf4427 LC |
1421 | features. |
1422 | ||
1423 | This chapter describes the main features of Guix, as well as the package | |
deb6276d AK |
1424 | management tools it provides. Along with the command-line interface |
1425 | described below (@pxref{Invoking guix package, @code{guix package}}), | |
1426 | you may also use Emacs Interface, after installing @code{emacs-guix} | |
1427 | package (run @kbd{M-x guix-help} command to start with it): | |
1428 | ||
1429 | @example | |
1430 | guix package -i emacs-guix | |
1431 | @end example | |
eeaf4427 LC |
1432 | |
1433 | @menu | |
1434 | * Features:: How Guix will make your life brighter. | |
e49951eb | 1435 | * Invoking guix package:: Package installation, removal, etc. |
c4202d60 | 1436 | * Substitutes:: Downloading pre-built binaries. |
760c60d6 | 1437 | * Packages with Multiple Outputs:: Single source package, multiple outputs. |
e49951eb | 1438 | * Invoking guix gc:: Running the garbage collector. |
f651b477 | 1439 | * Invoking guix pull:: Fetching the latest Guix and distribution. |
239c2266 | 1440 | * Invoking guix pack:: Creating software bundles. |
760c60d6 | 1441 | * Invoking guix archive:: Exporting and importing store files. |
eeaf4427 LC |
1442 | @end menu |
1443 | ||
1444 | @node Features | |
1445 | @section Features | |
1446 | ||
1447 | When using Guix, each package ends up in the @dfn{package store}, in its | |
1448 | own directory---something that resembles | |
deb6276d | 1449 | @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string. |
eeaf4427 LC |
1450 | |
1451 | Instead of referring to these directories, users have their own | |
1452 | @dfn{profile}, which points to the packages that they actually want to | |
821b0015 LC |
1453 | use. These profiles are stored within each user's home directory, at |
1454 | @code{$HOME/.guix-profile}. | |
eeaf4427 | 1455 | |
821b0015 | 1456 | For example, @code{alice} installs GCC 4.7.2. As a result, |
eeaf4427 | 1457 | @file{/home/alice/.guix-profile/bin/gcc} points to |
834129e0 | 1458 | @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine, |
821b0015 LC |
1459 | @code{bob} had already installed GCC 4.8.0. The profile of @code{bob} |
1460 | simply continues to point to | |
834129e0 | 1461 | @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC |
821b0015 | 1462 | coexist on the same system without any interference. |
eeaf4427 | 1463 | |
e49951eb | 1464 | The @command{guix package} command is the central tool to manage |
f97c9175 | 1465 | packages (@pxref{Invoking guix package}). It operates on the per-user |
821b0015 | 1466 | profiles, and can be used @emph{with normal user privileges}. |
eeaf4427 | 1467 | |
e32171ee | 1468 | @cindex transactions |
eeaf4427 LC |
1469 | The command provides the obvious install, remove, and upgrade |
1470 | operations. Each invocation is actually a @emph{transaction}: either | |
ba55b1cb | 1471 | the specified operation succeeds, or nothing happens. Thus, if the |
e49951eb | 1472 | @command{guix package} process is terminated during the transaction, |
eeaf4427 LC |
1473 | or if a power outage occurs during the transaction, then the user's |
1474 | profile remains in its previous state, and remains usable. | |
1475 | ||
1476 | In addition, any package transaction may be @emph{rolled back}. So, if, | |
1477 | for example, an upgrade installs a new version of a package that turns | |
1478 | out to have a serious bug, users may roll back to the previous instance | |
4af2447e | 1479 | of their profile, which was known to work well. Similarly, the global |
6f773606 LC |
1480 | system configuration on GuixSD is subject to |
1481 | transactional upgrades and roll-back | |
4af2447e | 1482 | (@pxref{Using the Configuration System}). |
eeaf4427 | 1483 | |
f97c9175 AE |
1484 | All packages in the package store may be @emph{garbage-collected}. |
1485 | Guix can determine which packages are still referenced by user | |
fe8ff028 | 1486 | profiles, and remove those that are provably no longer referenced |
e49951eb | 1487 | (@pxref{Invoking guix gc}). Users may also explicitly remove old |
fe8ff028 LC |
1488 | generations of their profile so that the packages they refer to can be |
1489 | collected. | |
eeaf4427 | 1490 | |
e900c503 LC |
1491 | @cindex reproducibility |
1492 | @cindex reproducible builds | |
eeaf4427 LC |
1493 | Finally, Guix takes a @dfn{purely functional} approach to package |
1494 | management, as described in the introduction (@pxref{Introduction}). | |
834129e0 | 1495 | Each @file{/gnu/store} package directory name contains a hash of all the |
eeaf4427 LC |
1496 | inputs that were used to build that package---compiler, libraries, build |
1497 | scripts, etc. This direct correspondence allows users to make sure a | |
1498 | given package installation matches the current state of their | |
e900c503 LC |
1499 | distribution. It also helps maximize @dfn{build reproducibility}: |
1500 | thanks to the isolated build environments that are used, a given build | |
1501 | is likely to yield bit-identical files when performed on different | |
1502 | machines (@pxref{Invoking guix-daemon, container}). | |
eeaf4427 | 1503 | |
c4202d60 | 1504 | @cindex substitutes |
eeaf4427 | 1505 | This foundation allows Guix to support @dfn{transparent binary/source |
c4202d60 | 1506 | deployment}. When a pre-built binary for a @file{/gnu/store} item is |
18f2887b | 1507 | available from an external source---a @dfn{substitute}, Guix just |
c4202d60 LC |
1508 | downloads it and unpacks it; |
1509 | otherwise, it builds the package from source, locally | |
bf9eacd2 LC |
1510 | (@pxref{Substitutes}). Because build results are usually bit-for-bit |
1511 | reproducible, users do not have to trust servers that provide | |
1512 | substitutes: they can force a local build and @emph{challenge} providers | |
1513 | (@pxref{Invoking guix challenge}). | |
eeaf4427 | 1514 | |
f5fd4fd2 LC |
1515 | Control over the build environment is a feature that is also useful for |
1516 | developers. The @command{guix environment} command allows developers of | |
1517 | a package to quickly set up the right development environment for their | |
f97c9175 AE |
1518 | package, without having to manually install the dependencies of the |
1519 | package into their profile (@pxref{Invoking guix environment}). | |
f5fd4fd2 | 1520 | |
e49951eb MW |
1521 | @node Invoking guix package |
1522 | @section Invoking @command{guix package} | |
eeaf4427 | 1523 | |
e32171ee JD |
1524 | @cindex installing packages |
1525 | @cindex removing packages | |
1526 | @cindex package installation | |
1527 | @cindex package removal | |
e49951eb | 1528 | The @command{guix package} command is the tool that allows users to |
eeaf4427 LC |
1529 | install, upgrade, and remove packages, as well as rolling back to |
1530 | previous configurations. It operates only on the user's own profile, | |
1531 | and works with normal user privileges (@pxref{Features}). Its syntax | |
1532 | is: | |
1533 | ||
1534 | @example | |
e49951eb | 1535 | guix package @var{options} |
eeaf4427 | 1536 | @end example |
e32171ee | 1537 | @cindex transactions |
ba55b1cb | 1538 | Primarily, @var{options} specifies the operations to be performed during |
eeaf4427 | 1539 | the transaction. Upon completion, a new profile is created, but |
99bd74d5 | 1540 | previous @dfn{generations} of the profile remain available, should the user |
eeaf4427 LC |
1541 | want to roll back. |
1542 | ||
6447738c MW |
1543 | For example, to remove @code{lua} and install @code{guile} and |
1544 | @code{guile-cairo} in a single transaction: | |
1545 | ||
1546 | @example | |
1547 | guix package -r lua -i guile guile-cairo | |
1548 | @end example | |
1549 | ||
99bd74d5 LC |
1550 | @command{guix package} also supports a @dfn{declarative approach} |
1551 | whereby the user specifies the exact set of packages to be available and | |
1552 | passes it @i{via} the @option{--manifest} option | |
1553 | (@pxref{profile-manifest, @option{--manifest}}). | |
1554 | ||
e32171ee | 1555 | @cindex profile |
b9e5c0a9 | 1556 | For each user, a symlink to the user's default profile is automatically |
0ec1af59 | 1557 | created in @file{$HOME/.guix-profile}. This symlink always points to the |
b9e5c0a9 LC |
1558 | current generation of the user's default profile. Thus, users can add |
1559 | @file{$HOME/.guix-profile/bin} to their @code{PATH} environment | |
1560 | variable, and so on. | |
d664f1b4 LC |
1561 | @cindex search paths |
1562 | If you are not using the Guix System Distribution, consider adding the | |
1563 | following lines to your @file{~/.bash_profile} (@pxref{Bash Startup | |
1564 | Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned | |
1565 | shells get all the right environment variable definitions: | |
1566 | ||
1567 | @example | |
1568 | GUIX_PROFILE="$HOME/.guix-profile" \ | |
1569 | source "$HOME/.guix-profile/etc/profile" | |
1570 | @end example | |
b9e5c0a9 | 1571 | |
4379c35b LC |
1572 | In a multi-user setup, user profiles are stored in a place registered as |
1573 | a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points | |
1574 | to (@pxref{Invoking guix gc}). That directory is normally | |
0ec1af59 LC |
1575 | @code{@var{localstatedir}/profiles/per-user/@var{user}}, where |
1576 | @var{localstatedir} is the value passed to @code{configure} as | |
4379c35b LC |
1577 | @code{--localstatedir}, and @var{user} is the user name. The |
1578 | @file{per-user} directory is created when @command{guix-daemon} is | |
1579 | started, and the @var{user} sub-directory is created by @command{guix | |
1580 | package}. | |
0ec1af59 LC |
1581 | |
1582 | The @var{options} can be among the following: | |
1583 | ||
eeaf4427 LC |
1584 | @table @code |
1585 | ||
6447738c MW |
1586 | @item --install=@var{package} @dots{} |
1587 | @itemx -i @var{package} @dots{} | |
1588 | Install the specified @var{package}s. | |
eeaf4427 | 1589 | |
6447738c | 1590 | Each @var{package} may specify either a simple package name, such as |
1b846da8 ML |
1591 | @code{guile}, or a package name followed by an at-sign and version number, |
1592 | such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter | |
724311a2 LC |
1593 | case, the newest version prefixed by @code{1.8} is selected.) |
1594 | ||
1595 | If no version number is specified, the | |
dc5669cd MW |
1596 | newest available version will be selected. In addition, @var{package} |
1597 | may contain a colon, followed by the name of one of the outputs of the | |
1b846da8 | 1598 | package, as in @code{gcc:doc} or @code{binutils@@2.22:lib} |
e7f34eb0 LC |
1599 | (@pxref{Packages with Multiple Outputs}). Packages with a corresponding |
1600 | name (and optionally version) are searched for among the GNU | |
1601 | distribution modules (@pxref{Package Modules}). | |
eeaf4427 | 1602 | |
461572cc LC |
1603 | @cindex propagated inputs |
1604 | Sometimes packages have @dfn{propagated inputs}: these are dependencies | |
21461f27 LC |
1605 | that automatically get installed along with the required package |
1606 | (@pxref{package-propagated-inputs, @code{propagated-inputs} in | |
1607 | @code{package} objects}, for information about propagated inputs in | |
1608 | package definitions). | |
461572cc | 1609 | |
21461f27 | 1610 | @anchor{package-cmd-propagated-inputs} |
461572cc LC |
1611 | An example is the GNU MPC library: its C header files refer to those of |
1612 | the GNU MPFR library, which in turn refer to those of the GMP library. | |
1613 | Thus, when installing MPC, the MPFR and GMP libraries also get installed | |
1614 | in the profile; removing MPC also removes MPFR and GMP---unless they had | |
f97c9175 | 1615 | also been explicitly installed by the user. |
461572cc | 1616 | |
ba7ea5ce | 1617 | Besides, packages sometimes rely on the definition of environment |
5924080d | 1618 | variables for their search paths (see explanation of |
ba7ea5ce | 1619 | @code{--search-paths} below). Any missing or possibly incorrect |
5924080d LC |
1620 | environment variable definitions are reported here. |
1621 | ||
5d4b411f LC |
1622 | @item --install-from-expression=@var{exp} |
1623 | @itemx -e @var{exp} | |
1624 | Install the package @var{exp} evaluates to. | |
1625 | ||
1626 | @var{exp} must be a Scheme expression that evaluates to a | |
1627 | @code{<package>} object. This option is notably useful to disambiguate | |
1628 | between same-named variants of a package, with expressions such as | |
1629 | @code{(@@ (gnu packages base) guile-final)}. | |
1630 | ||
1631 | Note that this option installs the first output of the specified | |
1632 | package, which may be insufficient when needing a specific output of a | |
1633 | multiple-output package. | |
1634 | ||
0d279400 DT |
1635 | @item --install-from-file=@var{file} |
1636 | @itemx -f @var{file} | |
1637 | Install the package that the code within @var{file} evaluates to. | |
1638 | ||
1639 | As an example, @var{file} might contain a definition like this | |
1640 | (@pxref{Defining Packages}): | |
1641 | ||
1642 | @example | |
1643 | @verbatiminclude package-hello.scm | |
1644 | @end example | |
1645 | ||
baacf042 | 1646 | Developers may find it useful to include such a @file{guix.scm} file |
f97c9175 | 1647 | in the root of their project source tree that can be used to test |
0d279400 DT |
1648 | development snapshots and create reproducible development environments |
1649 | (@pxref{Invoking guix environment}). | |
1650 | ||
6447738c MW |
1651 | @item --remove=@var{package} @dots{} |
1652 | @itemx -r @var{package} @dots{} | |
1653 | Remove the specified @var{package}s. | |
eeaf4427 | 1654 | |
6447738c | 1655 | As for @code{--install}, each @var{package} may specify a version number |
13ed095c LC |
1656 | and/or output name in addition to the package name. For instance, |
1657 | @code{-r glibc:debug} would remove the @code{debug} output of | |
1658 | @code{glibc}. | |
1659 | ||
6447738c MW |
1660 | @item --upgrade[=@var{regexp} @dots{}] |
1661 | @itemx -u [@var{regexp} @dots{}] | |
e32171ee | 1662 | @cindex upgrading packages |
6447738c MW |
1663 | Upgrade all the installed packages. If one or more @var{regexp}s are |
1664 | specified, upgrade only installed packages whose name matches a | |
d5f01e48 | 1665 | @var{regexp}. Also see the @code{--do-not-upgrade} option below. |
eeaf4427 | 1666 | |
f651b477 LC |
1667 | Note that this upgrades package to the latest version of packages found |
1668 | in the distribution currently installed. To update your distribution, | |
1669 | you should regularly run @command{guix pull} (@pxref{Invoking guix | |
1670 | pull}). | |
1671 | ||
d5f01e48 MW |
1672 | @item --do-not-upgrade[=@var{regexp} @dots{}] |
1673 | When used together with the @code{--upgrade} option, do @emph{not} | |
1674 | upgrade any packages whose name matches a @var{regexp}. For example, to | |
1675 | upgrade all packages in the current profile except those containing the | |
1676 | substring ``emacs'': | |
1677 | ||
1678 | @example | |
1679 | $ guix package --upgrade . --do-not-upgrade emacs | |
1680 | @end example | |
1681 | ||
99bd74d5 | 1682 | @item @anchor{profile-manifest}--manifest=@var{file} |
1b676447 | 1683 | @itemx -m @var{file} |
99bd74d5 LC |
1684 | @cindex profile declaration |
1685 | @cindex profile manifest | |
1686 | Create a new generation of the profile from the manifest object | |
1b676447 DT |
1687 | returned by the Scheme code in @var{file}. |
1688 | ||
99bd74d5 LC |
1689 | This allows you to @emph{declare} the profile's contents rather than |
1690 | constructing it through a sequence of @code{--install} and similar | |
1691 | commands. The advantage is that @var{file} can be put under version | |
1692 | control, copied to different machines to reproduce the same profile, and | |
1693 | so on. | |
1694 | ||
1695 | @c FIXME: Add reference to (guix profile) documentation when available. | |
1696 | @var{file} must return a @dfn{manifest} object, which is roughly a list | |
1697 | of packages: | |
1b676447 | 1698 | |
99bd74d5 | 1699 | @findex packages->manifest |
1b676447 | 1700 | @example |
99bd74d5 | 1701 | (use-package-modules guile emacs) |
1b676447 DT |
1702 | |
1703 | (packages->manifest | |
99bd74d5 LC |
1704 | (list emacs |
1705 | guile-2.0 | |
1b676447 | 1706 | ;; Use a specific package output. |
99bd74d5 | 1707 | (list guile-2.0 "debug"))) |
1b676447 DT |
1708 | @end example |
1709 | ||
6cd10593 LC |
1710 | @findex specification->package+output |
1711 | In this example we have to know which modules define the @code{emacs} | |
1712 | and @code{guile-2.0} variables to provide the right | |
1713 | @code{use-package-modules} line, which can be cumbersome. We can | |
1714 | instead provide regular package specifications and let | |
1715 | @code{specification->package-output} look up the corresponding package | |
1716 | objects, like this: | |
1717 | ||
1718 | @example | |
1719 | (packages->manifest | |
1720 | (map (compose list specification->package+output) | |
1721 | '("emacs" "guile@@2.0" "guile@@2.0:debug"))) | |
1722 | @end example | |
1723 | ||
24e262f0 | 1724 | @item --roll-back |
e32171ee JD |
1725 | @cindex rolling back |
1726 | @cindex undoing transactions | |
1727 | @cindex transactions, undoing | |
24e262f0 LC |
1728 | Roll back to the previous @dfn{generation} of the profile---i.e., undo |
1729 | the last transaction. | |
1730 | ||
1731 | When combined with options such as @code{--install}, roll back occurs | |
1732 | before any other actions. | |
1733 | ||
d9307267 | 1734 | When rolling back from the first generation that actually contains |
4b2bc804 | 1735 | installed packages, the profile is made to point to the @dfn{zeroth |
f97c9175 | 1736 | generation}, which contains no files apart from its own metadata. |
d9307267 | 1737 | |
f97c9175 AE |
1738 | After having rolled back, installing, removing, or upgrading packages |
1739 | overwrites previous future generations. Thus, the history of the | |
1740 | generations in a profile is always linear. | |
82fe08ed | 1741 | |
b3bb82f1 AK |
1742 | @item --switch-generation=@var{pattern} |
1743 | @itemx -S @var{pattern} | |
e32171ee | 1744 | @cindex generations |
b3bb82f1 AK |
1745 | Switch to a particular generation defined by @var{pattern}. |
1746 | ||
1747 | @var{pattern} may be either a generation number or a number prefixed | |
1748 | with ``+'' or ``-''. The latter means: move forward/backward by a | |
1749 | specified number of generations. For example, if you want to return to | |
1750 | the latest generation after @code{--roll-back}, use | |
1751 | @code{--switch-generation=+1}. | |
1752 | ||
1753 | The difference between @code{--roll-back} and | |
1754 | @code{--switch-generation=-1} is that @code{--switch-generation} will | |
1755 | not make a zeroth generation, so if a specified generation does not | |
1756 | exist, the current generation will not be changed. | |
1757 | ||
dbc31ab2 | 1758 | @item --search-paths[=@var{kind}] |
5924080d LC |
1759 | @cindex search paths |
1760 | Report environment variable definitions, in Bash syntax, that may be | |
1761 | needed in order to use the set of installed packages. These environment | |
1762 | variables are used to specify @dfn{search paths} for files used by some | |
1763 | of the installed packages. | |
1764 | ||
1765 | For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH} | |
1766 | environment variables to be defined so it can look for headers and | |
1767 | libraries in the user's profile (@pxref{Environment Variables,,, gcc, | |
1768 | Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C | |
1769 | library are installed in the profile, then @code{--search-paths} will | |
1770 | suggest setting these variables to @code{@var{profile}/include} and | |
1771 | @code{@var{profile}/lib}, respectively. | |
1772 | ||
dbc31ab2 LC |
1773 | The typical use case is to define these environment variables in the |
1774 | shell: | |
1775 | ||
1776 | @example | |
1777 | $ eval `guix package --search-paths` | |
1778 | @end example | |
1779 | ||
1780 | @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix}, | |
1781 | meaning that the returned environment variable definitions will either | |
1782 | be exact settings, or prefixes or suffixes of the current value of these | |
1783 | variables. When omitted, @var{kind} defaults to @code{exact}. | |
1784 | ||
fc2d2339 LC |
1785 | This option can also be used to compute the @emph{combined} search paths |
1786 | of several profiles. Consider this example: | |
1787 | ||
1788 | @example | |
1789 | $ guix package -p foo -i guile | |
1790 | $ guix package -p bar -i guile-json | |
1791 | $ guix package -p foo -p bar --search-paths | |
1792 | @end example | |
1793 | ||
1794 | The last command above reports about the @code{GUILE_LOAD_PATH} | |
1795 | variable, even though, taken individually, neither @file{foo} nor | |
1796 | @file{bar} would lead to that recommendation. | |
1797 | ||
1798 | ||
eeaf4427 LC |
1799 | @item --profile=@var{profile} |
1800 | @itemx -p @var{profile} | |
1801 | Use @var{profile} instead of the user's default profile. | |
1802 | ||
70915c1a | 1803 | @item --verbose |
f97c9175 AE |
1804 | Produce verbose output. In particular, emit the build log of the |
1805 | environment on the standard error port. | |
70915c1a | 1806 | |
eeaf4427 LC |
1807 | @item --bootstrap |
1808 | Use the bootstrap Guile to build the profile. This option is only | |
1809 | useful to distribution developers. | |
1810 | ||
1811 | @end table | |
1812 | ||
f97c9175 | 1813 | In addition to these actions, @command{guix package} supports the |
733b4130 LC |
1814 | following options to query the current state of a profile, or the |
1815 | availability of packages: | |
eeaf4427 | 1816 | |
733b4130 LC |
1817 | @table @option |
1818 | ||
acc08466 NK |
1819 | @item --search=@var{regexp} |
1820 | @itemx -s @var{regexp} | |
b110869d | 1821 | @cindex searching for packages |
5763ad92 | 1822 | List the available packages whose name, synopsis, or description matches |
f97c9175 | 1823 | @var{regexp}. Print all the metadata of matching packages in |
299112d3 LC |
1824 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, |
1825 | GNU recutils manual}). | |
acc08466 | 1826 | |
299112d3 LC |
1827 | This allows specific fields to be extracted using the @command{recsel} |
1828 | command, for instance: | |
1829 | ||
1830 | @example | |
e49951eb | 1831 | $ guix package -s malloc | recsel -p name,version |
299112d3 LC |
1832 | name: glibc |
1833 | version: 2.17 | |
1834 | ||
1835 | name: libgc | |
1836 | version: 7.2alpha6 | |
1837 | @end example | |
acc08466 | 1838 | |
a12d92f5 LC |
1839 | Similarly, to show the name of all the packages available under the |
1840 | terms of the GNU@tie{}LGPL version 3: | |
1841 | ||
1842 | @example | |
1843 | $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"' | |
1844 | name: elfutils | |
1845 | ||
1846 | name: gmp | |
1847 | @dots{} | |
1848 | @end example | |
1849 | ||
db5a9444 LC |
1850 | It is also possible to refine search results using several @code{-s} |
1851 | flags. For example, the following command returns a list of board | |
1852 | games: | |
1853 | ||
1854 | @example | |
1855 | $ guix package -s '\<board\>' -s game | recsel -p name | |
1856 | name: gnubg | |
1857 | @dots{} | |
1858 | @end example | |
1859 | ||
1860 | If we were to omit @code{-s game}, we would also get software packages | |
1861 | that deal with printed circuit boards; removing the angle brackets | |
1862 | around @code{board} would further add packages that have to do with | |
1863 | keyboards. | |
1864 | ||
b110869d LC |
1865 | And now for a more elaborate example. The following command searches |
1866 | for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby | |
1867 | libraries, and prints the name and synopsis of the matching packages: | |
1868 | ||
1869 | @example | |
1870 | $ guix package -s crypto -s library | \ | |
1871 | recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis | |
1872 | @end example | |
1873 | ||
1874 | @noindent | |
1875 | @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more | |
1876 | information on @dfn{selection expressions} for @code{recsel -e}. | |
1877 | ||
2aa6efb0 CR |
1878 | @item --show=@var{package} |
1879 | Show details about @var{package}, taken from the list of available packages, in | |
1880 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU | |
1881 | recutils manual}). | |
1882 | ||
1883 | @example | |
1884 | $ guix package --show=python | recsel -p name,version | |
1885 | name: python | |
1886 | version: 2.7.6 | |
1887 | ||
1888 | name: python | |
1889 | version: 3.3.5 | |
1890 | @end example | |
1891 | ||
1892 | You may also specify the full name of a package to only get details about a | |
1893 | specific version of it: | |
1894 | @example | |
ea206df4 | 1895 | $ guix package --show=python@@3.4 | recsel -p name,version |
2aa6efb0 | 1896 | name: python |
ea206df4 | 1897 | version: 3.4.3 |
2aa6efb0 CR |
1898 | @end example |
1899 | ||
1900 | ||
1901 | ||
733b4130 LC |
1902 | @item --list-installed[=@var{regexp}] |
1903 | @itemx -I [@var{regexp}] | |
bd9bde1c LC |
1904 | List the currently installed packages in the specified profile, with the |
1905 | most recently installed packages shown last. When @var{regexp} is | |
1906 | specified, list only installed packages whose name matches @var{regexp}. | |
733b4130 LC |
1907 | |
1908 | For each installed package, print the following items, separated by | |
1909 | tabs: the package name, its version string, the part of the package that | |
1910 | is installed (for instance, @code{out} for the default output, | |
1911 | @code{include} for its headers, etc.), and the path of this package in | |
1912 | the store. | |
1913 | ||
64fc89b6 LC |
1914 | @item --list-available[=@var{regexp}] |
1915 | @itemx -A [@var{regexp}] | |
5763ad92 | 1916 | List packages currently available in the distribution for this system |
a1ba8475 LC |
1917 | (@pxref{GNU Distribution}). When @var{regexp} is specified, list only |
1918 | installed packages whose name matches @var{regexp}. | |
64fc89b6 LC |
1919 | |
1920 | For each package, print the following items separated by tabs: its name, | |
6e721c4d LC |
1921 | its version string, the parts of the package (@pxref{Packages with |
1922 | Multiple Outputs}), and the source location of its definition. | |
64fc89b6 | 1923 | |
f566d765 LC |
1924 | @item --list-generations[=@var{pattern}] |
1925 | @itemx -l [@var{pattern}] | |
e32171ee | 1926 | @cindex generations |
f566d765 LC |
1927 | Return a list of generations along with their creation dates; for each |
1928 | generation, show the installed packages, with the most recently | |
4b2bc804 NK |
1929 | installed packages shown last. Note that the zeroth generation is never |
1930 | shown. | |
f566d765 LC |
1931 | |
1932 | For each installed package, print the following items, separated by | |
1933 | tabs: the name of a package, its version string, the part of the package | |
1934 | that is installed (@pxref{Packages with Multiple Outputs}), and the | |
1935 | location of this package in the store. | |
1936 | ||
1937 | When @var{pattern} is used, the command returns only matching | |
1938 | generations. Valid patterns include: | |
1939 | ||
1940 | @itemize | |
1941 | @item @emph{Integers and comma-separated integers}. Both patterns denote | |
1942 | generation numbers. For instance, @code{--list-generations=1} returns | |
1943 | the first one. | |
1944 | ||
1945 | And @code{--list-generations=1,8,2} outputs three generations in the | |
1946 | specified order. Neither spaces nor trailing commas are allowed. | |
1947 | ||
1948 | @item @emph{Ranges}. @code{--list-generations=2..9} prints the | |
1949 | specified generations and everything in between. Note that the start of | |
f97c9175 | 1950 | a range must be smaller than its end. |
f566d765 LC |
1951 | |
1952 | It is also possible to omit the endpoint. For example, | |
1953 | @code{--list-generations=2..}, returns all generations starting from the | |
1954 | second one. | |
1955 | ||
1956 | @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks, | |
1957 | or months by passing an integer along with the first letter of the | |
d7ddb257 LC |
1958 | duration. For example, @code{--list-generations=20d} lists generations |
1959 | that are up to 20 days old. | |
f566d765 LC |
1960 | @end itemize |
1961 | ||
b7884ca3 NK |
1962 | @item --delete-generations[=@var{pattern}] |
1963 | @itemx -d [@var{pattern}] | |
d7ddb257 LC |
1964 | When @var{pattern} is omitted, delete all generations except the current |
1965 | one. | |
b7884ca3 NK |
1966 | |
1967 | This command accepts the same patterns as @option{--list-generations}. | |
d7ddb257 LC |
1968 | When @var{pattern} is specified, delete the matching generations. When |
1969 | @var{pattern} specifies a duration, generations @emph{older} than the | |
1970 | specified duration match. For instance, @code{--delete-generations=1m} | |
1971 | deletes generations that are more than one month old. | |
1972 | ||
391bdd8f LC |
1973 | If the current generation matches, it is @emph{not} deleted. Also, the |
1974 | zeroth generation is never deleted. | |
b7884ca3 | 1975 | |
f97c9175 | 1976 | Note that deleting generations prevents rolling back to them. |
1bb9900a LC |
1977 | Consequently, this command must be used with care. |
1978 | ||
733b4130 | 1979 | @end table |
eeaf4427 | 1980 | |
70ee5642 | 1981 | Finally, since @command{guix package} may actually start build |
ccd7158d | 1982 | processes, it supports all the common build options (@pxref{Common Build |
f97c9175 | 1983 | Options}). It also supports package transformation options, such as |
b8638f03 LC |
1984 | @option{--with-source} (@pxref{Package Transformation Options}). |
1985 | However, note that package transformations are lost when upgrading; to | |
f97c9175 | 1986 | preserve transformations across upgrades, you should define your own |
b8638f03 LC |
1987 | package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH} |
1988 | (@pxref{Defining Packages}). | |
1989 | ||
70ee5642 | 1990 | |
c4202d60 LC |
1991 | @node Substitutes |
1992 | @section Substitutes | |
1993 | ||
1994 | @cindex substitutes | |
1995 | @cindex pre-built binaries | |
1996 | Guix supports transparent source/binary deployment, which means that it | |
1997 | can either build things locally, or download pre-built items from a | |
1998 | server. We call these pre-built items @dfn{substitutes}---they are | |
1999 | substitutes for local build results. In many cases, downloading a | |
2000 | substitute is much faster than building things locally. | |
2001 | ||
2002 | Substitutes can be anything resulting from a derivation build | |
2003 | (@pxref{Derivations}). Of course, in the common case, they are | |
2004 | pre-built package binaries, but source tarballs, for instance, which | |
2005 | also result from derivation builds, can be available as substitutes. | |
2006 | ||
2007 | The @code{hydra.gnu.org} server is a front-end to a build farm that | |
2008 | builds packages from the GNU distribution continuously for some | |
deb6276d | 2009 | architectures, and makes them available as substitutes. This is the |
f8a8e0fe LC |
2010 | default source of substitutes; it can be overridden by passing the |
2011 | @option{--substitute-urls} option either to @command{guix-daemon} | |
2012 | (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}}) | |
2013 | or to client tools such as @command{guix package} | |
2014 | (@pxref{client-substitute-urls,, client @option{--substitute-urls} | |
2015 | option}). | |
c4202d60 | 2016 | |
1dbe3a8d | 2017 | Substitute URLs can be either HTTP or HTTPS. |
9b7bd1b1 LC |
2018 | HTTPS is recommended because communications are encrypted; conversely, |
2019 | using HTTP makes all communications visible to an eavesdropper, who | |
2020 | could use the information gathered to determine, for instance, whether | |
2021 | your system has unpatched security vulnerabilities. | |
2022 | ||
c4202d60 LC |
2023 | @cindex security |
2024 | @cindex digital signatures | |
e32171ee | 2025 | @cindex substitutes, authorization thereof |
df061d07 LC |
2026 | To allow Guix to download substitutes from @code{hydra.gnu.org} or a |
2027 | mirror thereof, you | |
c4202d60 LC |
2028 | must add its public key to the access control list (ACL) of archive |
2029 | imports, using the @command{guix archive} command (@pxref{Invoking guix | |
2030 | archive}). Doing so implies that you trust @code{hydra.gnu.org} to not | |
2031 | be compromised and to serve genuine substitutes. | |
2032 | ||
2033 | This public key is installed along with Guix, in | |
2034 | @code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is | |
2035 | the installation prefix of Guix. If you installed Guix from source, | |
2036 | make sure you checked the GPG signature of | |
2037 | @file{guix-@value{VERSION}.tar.gz}, which contains this public key file. | |
2038 | Then, you can run something like this: | |
2039 | ||
2040 | @example | |
2041 | # guix archive --authorize < hydra.gnu.org.pub | |
2042 | @end example | |
2043 | ||
2044 | Once this is in place, the output of a command like @code{guix build} | |
2045 | should change from something like: | |
2046 | ||
2047 | @example | |
2048 | $ guix build emacs --dry-run | |
2049 | The following derivations would be built: | |
2050 | /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv | |
2051 | /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv | |
2052 | /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv | |
2053 | /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv | |
2054 | @dots{} | |
2055 | @end example | |
2056 | ||
2057 | @noindent | |
2058 | to something like: | |
2059 | ||
2060 | @example | |
2061 | $ guix build emacs --dry-run | |
2062 | The following files would be downloaded: | |
2063 | /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3 | |
2064 | /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d | |
2065 | /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16 | |
2066 | /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7 | |
2067 | @dots{} | |
2068 | @end example | |
2069 | ||
2070 | @noindent | |
2071 | This indicates that substitutes from @code{hydra.gnu.org} are usable and | |
2072 | will be downloaded, when possible, for future builds. | |
2073 | ||
2074 | Guix ignores substitutes that are not signed, or that are not signed by | |
ef27aa9c | 2075 | one of the keys listed in the ACL. It also detects and raises an error |
c4202d60 LC |
2076 | when attempting to use a substitute that has been tampered with. |
2077 | ||
e0c941fe | 2078 | @vindex http_proxy |
9b7bd1b1 LC |
2079 | Substitutes are downloaded over HTTP or HTTPS. |
2080 | The @code{http_proxy} environment | |
e0c941fe LC |
2081 | variable can be set in the environment of @command{guix-daemon} and is |
2082 | honored for downloads of substitutes. Note that the value of | |
2083 | @code{http_proxy} in the environment where @command{guix build}, | |
2084 | @command{guix package}, and other client commands are run has | |
2085 | @emph{absolutely no effect}. | |
2086 | ||
9b7bd1b1 LC |
2087 | When using HTTPS, the server's X.509 certificate is @emph{not} validated |
2088 | (in other words, the server is not authenticated), contrary to what | |
2089 | HTTPS clients such as Web browsers usually do. This is because Guix | |
2090 | authenticates substitute information itself, as explained above, which | |
2091 | is what we care about (whereas X.509 certificates are about | |
2092 | authenticating bindings between domain names and public keys.) | |
2093 | ||
c4202d60 LC |
2094 | The substitute mechanism can be disabled globally by running |
2095 | @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking | |
2096 | guix-daemon}). It can also be disabled temporarily by passing the | |
2097 | @code{--no-substitutes} option to @command{guix package}, @command{guix | |
2098 | build}, and other command-line tools. | |
2099 | ||
2100 | ||
9b7bd1b1 LC |
2101 | @unnumberedsubsec On Trusting Binaries |
2102 | ||
c4202d60 LC |
2103 | Today, each individual's control over their own computing is at the |
2104 | mercy of institutions, corporations, and groups with enough power and | |
2105 | determination to subvert the computing infrastructure and exploit its | |
2106 | weaknesses. While using @code{hydra.gnu.org} substitutes can be | |
2107 | convenient, we encourage users to also build on their own, or even run | |
2108 | their own build farm, such that @code{hydra.gnu.org} is less of an | |
8ce229fc LC |
2109 | interesting target. One way to help is by publishing the software you |
2110 | build using @command{guix publish} so that others have one more choice | |
2111 | of server to download substitutes from (@pxref{Invoking guix publish}). | |
c4202d60 LC |
2112 | |
2113 | Guix has the foundations to maximize build reproducibility | |
2114 | (@pxref{Features}). In most cases, independent builds of a given | |
2115 | package or derivation should yield bit-identical results. Thus, through | |
2116 | a diverse set of independent package builds, we can strengthen the | |
d23c20f1 LC |
2117 | integrity of our systems. The @command{guix challenge} command aims to |
2118 | help users assess substitute servers, and to assist developers in | |
2119 | finding out about non-deterministic package builds (@pxref{Invoking guix | |
a8d65643 LC |
2120 | challenge}). Similarly, the @option{--check} option of @command{guix |
2121 | build} allows users to check whether previously-installed substitutes | |
2122 | are genuine by rebuilding them locally (@pxref{build-check, | |
2123 | @command{guix build --check}}). | |
c4202d60 LC |
2124 | |
2125 | In the future, we want Guix to have support to publish and retrieve | |
2126 | binaries to/from other users, in a peer-to-peer fashion. If you would | |
2127 | like to discuss this project, join us on @email{guix-devel@@gnu.org}. | |
2128 | ||
2129 | ||
6e721c4d LC |
2130 | @node Packages with Multiple Outputs |
2131 | @section Packages with Multiple Outputs | |
2132 | ||
2133 | @cindex multiple-output packages | |
2134 | @cindex package outputs | |
e32171ee | 2135 | @cindex outputs |
6e721c4d LC |
2136 | |
2137 | Often, packages defined in Guix have a single @dfn{output}---i.e., the | |
f97c9175 | 2138 | source package leads to exactly one directory in the store. When running |
6e721c4d LC |
2139 | @command{guix package -i glibc}, one installs the default output of the |
2140 | GNU libc package; the default output is called @code{out}, but its name | |
2141 | can be omitted as shown in this command. In this particular case, the | |
2142 | default output of @code{glibc} contains all the C header files, shared | |
2143 | libraries, static libraries, Info documentation, and other supporting | |
2144 | files. | |
2145 | ||
2146 | Sometimes it is more appropriate to separate the various types of files | |
2147 | produced from a single source package into separate outputs. For | |
2148 | instance, the GLib C library (used by GTK+ and related packages) | |
2149 | installs more than 20 MiB of reference documentation as HTML pages. | |
2150 | To save space for users who do not need it, the documentation goes to a | |
2151 | separate output, called @code{doc}. To install the main GLib output, | |
2152 | which contains everything but the documentation, one would run: | |
2153 | ||
2154 | @example | |
2155 | guix package -i glib | |
2156 | @end example | |
2157 | ||
e32171ee | 2158 | @cindex documentation |
6e721c4d LC |
2159 | The command to install its documentation is: |
2160 | ||
2161 | @example | |
2162 | guix package -i glib:doc | |
2163 | @end example | |
2164 | ||
2165 | Some packages install programs with different ``dependency footprints''. | |
f97c9175 | 2166 | For instance, the WordNet package installs both command-line tools and |
6e721c4d LC |
2167 | graphical user interfaces (GUIs). The former depend solely on the C |
2168 | library, whereas the latter depend on Tcl/Tk and the underlying X | |
2169 | libraries. In this case, we leave the command-line tools in the default | |
2170 | output, whereas the GUIs are in a separate output. This allows users | |
fcc58db6 LC |
2171 | who do not need the GUIs to save space. The @command{guix size} command |
2172 | can help find out about such situations (@pxref{Invoking guix size}). | |
88856916 | 2173 | @command{guix graph} can also be helpful (@pxref{Invoking guix graph}). |
6e721c4d LC |
2174 | |
2175 | There are several such multiple-output packages in the GNU distribution. | |
91ef73d4 LC |
2176 | Other conventional output names include @code{lib} for libraries and |
2177 | possibly header files, @code{bin} for stand-alone programs, and | |
2178 | @code{debug} for debugging information (@pxref{Installing Debugging | |
2179 | Files}). The outputs of a packages are listed in the third column of | |
2180 | the output of @command{guix package --list-available} (@pxref{Invoking | |
2181 | guix package}). | |
6e721c4d | 2182 | |
eeaf4427 | 2183 | |
e49951eb MW |
2184 | @node Invoking guix gc |
2185 | @section Invoking @command{guix gc} | |
fe8ff028 LC |
2186 | |
2187 | @cindex garbage collector | |
e32171ee | 2188 | @cindex disk space |
f97c9175 | 2189 | Packages that are installed, but not used, may be @dfn{garbage-collected}. |
e49951eb | 2190 | The @command{guix gc} command allows users to explicitly run the garbage |
c22eb992 LC |
2191 | collector to reclaim space from the @file{/gnu/store} directory. It is |
2192 | the @emph{only} way to remove files from @file{/gnu/store}---removing | |
2193 | files or directories manually may break it beyond repair! | |
fe8ff028 LC |
2194 | |
2195 | The garbage collector has a set of known @dfn{roots}: any file under | |
834129e0 | 2196 | @file{/gnu/store} reachable from a root is considered @dfn{live} and |
fe8ff028 LC |
2197 | cannot be deleted; any other file is considered @dfn{dead} and may be |
2198 | deleted. The set of garbage collector roots includes default user | |
e49951eb MW |
2199 | profiles, and may be augmented with @command{guix build --root}, for |
2200 | example (@pxref{Invoking guix build}). | |
fe8ff028 | 2201 | |
1bb9900a LC |
2202 | Prior to running @code{guix gc --collect-garbage} to make space, it is |
2203 | often useful to remove old generations from user profiles; that way, old | |
2204 | package builds referenced by those generations can be reclaimed. This | |
2205 | is achieved by running @code{guix package --delete-generations} | |
2206 | (@pxref{Invoking guix package}). | |
2207 | ||
e49951eb | 2208 | The @command{guix gc} command has three modes of operation: it can be |
fe8ff028 | 2209 | used to garbage-collect any dead files (the default), to delete specific |
7770aafc LC |
2210 | files (the @code{--delete} option), to print garbage-collector |
2211 | information, or for more advanced queries. The garbage collection | |
2212 | options are as follows: | |
fe8ff028 LC |
2213 | |
2214 | @table @code | |
2215 | @item --collect-garbage[=@var{min}] | |
2216 | @itemx -C [@var{min}] | |
834129e0 | 2217 | Collect garbage---i.e., unreachable @file{/gnu/store} files and |
fe8ff028 LC |
2218 | sub-directories. This is the default operation when no option is |
2219 | specified. | |
2220 | ||
2221 | When @var{min} is given, stop once @var{min} bytes have been collected. | |
2222 | @var{min} may be a number of bytes, or it may include a unit as a | |
4a44d7bb LC |
2223 | suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes |
2224 | (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}). | |
fe8ff028 LC |
2225 | |
2226 | When @var{min} is omitted, collect all the garbage. | |
2227 | ||
0054e470 LC |
2228 | @item --free-space=@var{free} |
2229 | @itemx -F @var{free} | |
2230 | Collect garbage until @var{free} space is available under | |
2231 | @file{/gnu/store}, if possible; @var{free} denotes storage space, such | |
2232 | as @code{500MiB}, as described above. | |
2233 | ||
2234 | When @var{free} or more is already available in @file{/gnu/store}, do | |
2235 | nothing and exit immediately. | |
2236 | ||
fe8ff028 LC |
2237 | @item --delete |
2238 | @itemx -d | |
2239 | Attempt to delete all the store files and directories specified as | |
2240 | arguments. This fails if some of the files are not in the store, or if | |
2241 | they are still live. | |
2242 | ||
30d9aa54 LC |
2243 | @item --list-failures |
2244 | List store items corresponding to cached build failures. | |
2245 | ||
2246 | This prints nothing unless the daemon was started with | |
2247 | @option{--cache-failures} (@pxref{Invoking guix-daemon, | |
2248 | @option{--cache-failures}}). | |
2249 | ||
2250 | @item --clear-failures | |
2251 | Remove the specified store items from the failed-build cache. | |
2252 | ||
2253 | Again, this option only makes sense when the daemon is started with | |
2254 | @option{--cache-failures}. Otherwise, it does nothing. | |
2255 | ||
fe8ff028 LC |
2256 | @item --list-dead |
2257 | Show the list of dead files and directories still present in the | |
2258 | store---i.e., files and directories no longer reachable from any root. | |
2259 | ||
2260 | @item --list-live | |
2261 | Show the list of live store files and directories. | |
ba8b732d LC |
2262 | |
2263 | @end table | |
2264 | ||
2265 | In addition, the references among existing store files can be queried: | |
2266 | ||
2267 | @table @code | |
2268 | ||
2269 | @item --references | |
2270 | @itemx --referrers | |
e32171ee | 2271 | @cindex package dependencies |
ba8b732d LC |
2272 | List the references (respectively, the referrers) of store files given |
2273 | as arguments. | |
2274 | ||
8e59fdd5 LC |
2275 | @item --requisites |
2276 | @itemx -R | |
fcc58db6 | 2277 | @cindex closure |
8e59fdd5 LC |
2278 | List the requisites of the store files passed as arguments. Requisites |
2279 | include the store files themselves, their references, and the references | |
2280 | of these, recursively. In other words, the returned list is the | |
2281 | @dfn{transitive closure} of the store files. | |
2282 | ||
f97c9175 AE |
2283 | @xref{Invoking guix size}, for a tool to profile the size of the closure |
2284 | of an element. @xref{Invoking guix graph}, for a tool to visualize | |
88856916 | 2285 | the graph of references. |
fcc58db6 | 2286 | |
fe8ff028 LC |
2287 | @end table |
2288 | ||
7770aafc LC |
2289 | Lastly, the following options allow you to check the integrity of the |
2290 | store and to control disk usage. | |
2291 | ||
2292 | @table @option | |
2293 | ||
2294 | @item --verify[=@var{options}] | |
2295 | @cindex integrity, of the store | |
2296 | @cindex integrity checking | |
2297 | Verify the integrity of the store. | |
2298 | ||
2299 | By default, make sure that all the store items marked as valid in the | |
f97c9175 | 2300 | database of the daemon actually exist in @file{/gnu/store}. |
7770aafc | 2301 | |
f97c9175 | 2302 | When provided, @var{options} must be a comma-separated list containing one |
7770aafc LC |
2303 | or more of @code{contents} and @code{repair}. |
2304 | ||
7414de0a | 2305 | When passing @option{--verify=contents}, the daemon computes the |
f97c9175 | 2306 | content hash of each store item and compares it against its hash in the |
7770aafc LC |
2307 | database. Hash mismatches are reported as data corruptions. Because it |
2308 | traverses @emph{all the files in the store}, this command can take a | |
2309 | long time, especially on systems with a slow disk drive. | |
2310 | ||
2311 | @cindex repairing the store | |
6da5bb7b | 2312 | @cindex corruption, recovering from |
7770aafc LC |
2313 | Using @option{--verify=repair} or @option{--verify=contents,repair} |
2314 | causes the daemon to try to repair corrupt store items by fetching | |
2315 | substitutes for them (@pxref{Substitutes}). Because repairing is not | |
2316 | atomic, and thus potentially dangerous, it is available only to the | |
6da5bb7b LC |
2317 | system administrator. A lightweight alternative, when you know exactly |
2318 | which items in the store are corrupt, is @command{guix build --repair} | |
2319 | (@pxref{Invoking guix build}). | |
7770aafc LC |
2320 | |
2321 | @item --optimize | |
2322 | @cindex deduplication | |
2323 | Optimize the store by hard-linking identical files---this is | |
2324 | @dfn{deduplication}. | |
2325 | ||
2326 | The daemon performs deduplication after each successful build or archive | |
2327 | import, unless it was started with @code{--disable-deduplication} | |
2328 | (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus, | |
2329 | this option is primarily useful when the daemon was running with | |
2330 | @code{--disable-deduplication}. | |
2331 | ||
2332 | @end table | |
eeaf4427 | 2333 | |
f651b477 LC |
2334 | @node Invoking guix pull |
2335 | @section Invoking @command{guix pull} | |
2336 | ||
e32171ee | 2337 | @cindex upgrading Guix |
7fcf2a0b | 2338 | @cindex updating Guix |
e32171ee JD |
2339 | @cindex @command{guix pull} |
2340 | @cindex pull | |
f651b477 LC |
2341 | Packages are installed or upgraded to the latest version available in |
2342 | the distribution currently available on your local machine. To update | |
2343 | that distribution, along with the Guix tools, you must run @command{guix | |
2344 | pull}: the command downloads the latest Guix source code and package | |
2345 | descriptions, and deploys it. | |
2346 | ||
2347 | On completion, @command{guix package} will use packages and package | |
2348 | versions from this just-retrieved copy of Guix. Not only that, but all | |
2349 | the Guix commands and Scheme modules will also be taken from that latest | |
2350 | version. New @command{guix} sub-commands added by the update also | |
cb05108a LC |
2351 | become available. |
2352 | ||
2353 | Any user can update their Guix copy using @command{guix pull}, and the | |
2354 | effect is limited to the user who run @command{guix pull}. For | |
2355 | instance, when user @code{root} runs @command{guix pull}, this has no | |
2356 | effect on the version of Guix that user @code{alice} sees, and vice | |
2357 | versa@footnote{Under the hood, @command{guix pull} updates the | |
2358 | @file{~/.config/guix/latest} symbolic link to point to the latest Guix, | |
5e2017ed CM |
2359 | and the @command{guix} command loads code from there. Currently, the |
2360 | only way to roll back an invocation of @command{guix pull} is to | |
2361 | manually update this symlink to point to the previous Guix.}. | |
f651b477 LC |
2362 | |
2363 | The @command{guix pull} command is usually invoked with no arguments, | |
2364 | but it supports the following options: | |
2365 | ||
2366 | @table @code | |
2367 | @item --verbose | |
2368 | Produce verbose output, writing build logs to the standard error output. | |
2369 | ||
ab5d72ad LC |
2370 | @item --url=@var{url} |
2371 | Download the source tarball of Guix from @var{url}. | |
2372 | ||
2373 | By default, the tarball is taken from its canonical address at | |
2374 | @code{gnu.org}, for the stable branch of Guix. | |
2375 | ||
8a9cffb2 LF |
2376 | With some Git servers, this can be used to deploy any version of Guix. |
2377 | For example, to download and deploy version 0.12.0 of Guix from the | |
2378 | canonical Git repo: | |
2379 | ||
2380 | @example | |
2381 | guix pull --url=http://git.savannah.gnu.org/cgit/guix.git/snapshot/v0.12.0.tar.gz | |
2382 | @end example | |
2383 | ||
2384 | It can also be used to deploy arbitrary Git revisions: | |
2385 | ||
2386 | @example | |
2387 | guix pull --url=http://git.savannah.gnu.org/cgit/guix.git/snapshot/74d862e8a.tar.gz | |
2388 | @end example | |
2389 | ||
f651b477 LC |
2390 | @item --bootstrap |
2391 | Use the bootstrap Guile to build the latest Guix. This option is only | |
2392 | useful to Guix developers. | |
2393 | @end table | |
2394 | ||
760c60d6 | 2395 | |
239c2266 LC |
2396 | @node Invoking guix pack |
2397 | @section Invoking @command{guix pack} | |
2398 | ||
2399 | Occasionally you want to pass software to people who are not (yet!) | |
2400 | lucky enough to be using Guix. You'd tell them to run @command{guix | |
2401 | package -i @var{something}}, but that's not possible in this case. This | |
2402 | is where @command{guix pack} comes in. | |
2403 | ||
2404 | @cindex pack | |
2405 | @cindex bundle | |
2406 | @cindex application bundle | |
2407 | @cindex software bundle | |
2408 | The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or | |
2409 | @dfn{software bundle}: it creates a tarball or some other archive | |
2410 | containing the binaries of the software you're interested in, and all | |
2411 | its dependencies. The resulting archive can be used on any machine that | |
2412 | does not have Guix, and people can run the exact same binaries as those | |
107b8da6 LC |
2413 | you have with Guix. The pack itself is created in a bit-reproducible |
2414 | fashion, so anyone can verify that it really contains the build results | |
2415 | that you pretend to be shipping. | |
239c2266 LC |
2416 | |
2417 | For example, to create a bundle containing Guile, Emacs, Geiser, and all | |
2418 | their dependencies, you can run: | |
2419 | ||
2420 | @example | |
2421 | $ guix pack guile emacs geiser | |
2422 | @dots{} | |
2423 | /gnu/store/@dots{}-pack.tar.gz | |
2424 | @end example | |
2425 | ||
2426 | The result here is a tarball containing a @file{/gnu/store} directory | |
2427 | with all the relevant packages. The resulting tarball contains a | |
2428 | @dfn{profile} with the three packages of interest; the profile is the | |
2429 | same as would be created by @command{guix package -i}. It is this | |
2430 | mechanism that is used to create Guix's own standalone binary tarball | |
2431 | (@pxref{Binary Installation}). | |
2432 | ||
5895ec8a LC |
2433 | Users of this pack would have to run |
2434 | @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may | |
2435 | find inconvenient. To work around it, you can create, say, a | |
2436 | @file{/opt/gnu/bin} symlink to the profile: | |
2437 | ||
2438 | @example | |
2439 | guix pack -S /opt/gnu/bin=bin guile emacs geiser | |
2440 | @end example | |
2441 | ||
2442 | @noindent | |
2443 | That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy. | |
2444 | ||
708b54a9 LC |
2445 | Alternatively, you can produce a pack in the Docker image format using |
2446 | the following command: | |
b1edfbc3 LC |
2447 | |
2448 | @example | |
2449 | guix pack -f docker guile emacs geiser | |
2450 | @end example | |
2451 | ||
2452 | @noindent | |
2453 | The result is a tarball that can be passed to the @command{docker load} | |
2454 | command. See the | |
2455 | @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker | |
2456 | documentation} for more information. | |
2457 | ||
239c2266 LC |
2458 | Several command-line options allow you to customize your pack: |
2459 | ||
2460 | @table @code | |
708b54a9 LC |
2461 | @item --format=@var{format} |
2462 | @itemx -f @var{format} | |
2463 | Produce a pack in the given @var{format}. | |
2464 | ||
2465 | The available formats are: | |
2466 | ||
2467 | @table @code | |
2468 | @item tarball | |
2469 | This is the default format. It produces a tarball containing all the | |
2470 | specifies binaries and symlinks. | |
2471 | ||
2472 | @item docker | |
2473 | This produces a tarball that follows the | |
2474 | @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md, | |
2475 | Docker Image Specification}. | |
2476 | @end table | |
2477 | ||
239c2266 LC |
2478 | @item --system=@var{system} |
2479 | @itemx -s @var{system} | |
2480 | Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of | |
2481 | the system type of the build host. | |
2482 | ||
5461115e LC |
2483 | @item --target=@var{triplet} |
2484 | @cindex cross-compilation | |
2485 | Cross-build for @var{triplet}, which must be a valid GNU triplet, such | |
2486 | as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU | |
2487 | configuration triplets,, autoconf, Autoconf}). | |
2488 | ||
239c2266 LC |
2489 | @item --compression=@var{tool} |
2490 | @itemx -C @var{tool} | |
2491 | Compress the resulting tarball using @var{tool}---one of @code{gzip}, | |
2492 | @code{bzip2}, @code{xz}, or @code{lzip}. | |
6b63c43e | 2493 | |
5895ec8a LC |
2494 | @item --symlink=@var{spec} |
2495 | @itemx -S @var{spec} | |
2496 | Add the symlinks specified by @var{spec} to the pack. This option can | |
2497 | appear several times. | |
2498 | ||
2499 | @var{spec} has the form @code{@var{source}=@var{target}}, where | |
2500 | @var{source} is the symlink that will be created and @var{target} is the | |
2501 | symlink target. | |
2502 | ||
2503 | For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin} | |
2504 | symlink pointing to the @file{bin} sub-directory of the profile. | |
2505 | ||
6b63c43e LC |
2506 | @item --localstatedir |
2507 | Include the ``local state directory'', @file{/var/guix}, in the | |
2508 | resulting pack. | |
2509 | ||
2510 | @file{/var/guix} contains the store database (@pxref{The Store}) as well | |
2511 | as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in | |
2512 | the pack means that the store is ``complete'' and manageable by Guix; | |
2513 | not providing it pack means that the store is ``dead'': items cannot be | |
2514 | added to it or removed from it after extraction of the pack. | |
2515 | ||
2516 | One use case for this is the Guix self-contained binary tarball | |
2517 | (@pxref{Binary Installation}). | |
239c2266 LC |
2518 | @end table |
2519 | ||
2520 | In addition, @command{guix pack} supports all the common build options | |
2521 | (@pxref{Common Build Options}) and all the package transformation | |
2522 | options (@pxref{Package Transformation Options}). | |
2523 | ||
2524 | ||
760c60d6 LC |
2525 | @node Invoking guix archive |
2526 | @section Invoking @command{guix archive} | |
2527 | ||
e32171ee JD |
2528 | @cindex @command{guix archive} |
2529 | @cindex archive | |
760c60d6 LC |
2530 | The @command{guix archive} command allows users to @dfn{export} files |
2531 | from the store into a single archive, and to later @dfn{import} them. | |
2532 | In particular, it allows store files to be transferred from one machine | |
4d4c4816 AE |
2533 | to the store on another machine. |
2534 | ||
e32171ee | 2535 | @cindex exporting store items |
4d4c4816 AE |
2536 | To export store files as an archive to standard output, run: |
2537 | ||
2538 | @example | |
2539 | guix archive --export @var{options} @var{specifications}... | |
2540 | @end example | |
2541 | ||
2542 | @var{specifications} may be either store file names or package | |
2543 | specifications, as for @command{guix package} (@pxref{Invoking guix | |
2544 | package}). For instance, the following command creates an archive | |
2545 | containing the @code{gui} output of the @code{git} package and the main | |
2546 | output of @code{emacs}: | |
2547 | ||
2548 | @example | |
2549 | guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar | |
2550 | @end example | |
2551 | ||
2552 | If the specified packages are not built yet, @command{guix archive} | |
2553 | automatically builds them. The build process may be controlled with the | |
2554 | common build options (@pxref{Common Build Options}). | |
2555 | ||
2556 | To transfer the @code{emacs} package to a machine connected over SSH, | |
2557 | one would run: | |
760c60d6 LC |
2558 | |
2559 | @example | |
56607088 | 2560 | guix archive --export -r emacs | ssh the-machine guix archive --import |
760c60d6 LC |
2561 | @end example |
2562 | ||
87236aed | 2563 | @noindent |
56607088 LC |
2564 | Similarly, a complete user profile may be transferred from one machine |
2565 | to another like this: | |
2566 | ||
2567 | @example | |
2568 | guix archive --export -r $(readlink -f ~/.guix-profile) | \ | |
2569 | ssh the-machine guix-archive --import | |
2570 | @end example | |
2571 | ||
2572 | @noindent | |
2573 | However, note that, in both examples, all of @code{emacs} and the | |
2574 | profile as well as all of their dependencies are transferred (due to | |
f97c9175 AE |
2575 | @code{-r}), regardless of what is already available in the store on the |
2576 | target machine. The @code{--missing} option can help figure out which | |
f11c444d LC |
2577 | items are missing from the target store. The @command{guix copy} |
2578 | command simplifies and optimizes this whole process, so this is probably | |
2579 | what you should use in this case (@pxref{Invoking guix copy}). | |
87236aed | 2580 | |
5597b3ae LC |
2581 | @cindex nar, archive format |
2582 | @cindex normalized archive (nar) | |
b1edfbc3 | 2583 | Archives are stored in the ``normalized archive'' or ``nar'' format, which is |
5597b3ae | 2584 | comparable in spirit to `tar', but with differences |
0dbd88db | 2585 | that make it more appropriate for our purposes. First, rather than |
5597b3ae | 2586 | recording all Unix metadata for each file, the nar format only mentions |
0dbd88db LC |
2587 | the file type (regular, directory, or symbolic link); Unix permissions |
2588 | and owner/group are dismissed. Second, the order in which directory | |
2589 | entries are stored always follows the order of file names according to | |
2590 | the C locale collation order. This makes archive production fully | |
2591 | deterministic. | |
2592 | ||
2593 | When exporting, the daemon digitally signs the contents of the archive, | |
2594 | and that digital signature is appended. When importing, the daemon | |
2595 | verifies the signature and rejects the import in case of an invalid | |
2596 | signature or if the signing key is not authorized. | |
760c60d6 LC |
2597 | @c FIXME: Add xref to daemon doc about signatures. |
2598 | ||
2599 | The main options are: | |
2600 | ||
2601 | @table @code | |
2602 | @item --export | |
2603 | Export the specified store files or packages (see below.) Write the | |
2604 | resulting archive to the standard output. | |
2605 | ||
56607088 LC |
2606 | Dependencies are @emph{not} included in the output, unless |
2607 | @code{--recursive} is passed. | |
2608 | ||
2609 | @item -r | |
2610 | @itemx --recursive | |
2611 | When combined with @code{--export}, this instructs @command{guix | |
2612 | archive} to include dependencies of the given items in the archive. | |
2613 | Thus, the resulting archive is self-contained: it contains the closure | |
2614 | of the exported store items. | |
2615 | ||
760c60d6 LC |
2616 | @item --import |
2617 | Read an archive from the standard input, and import the files listed | |
2618 | therein into the store. Abort if the archive has an invalid digital | |
f82cc5fd LC |
2619 | signature, or if it is signed by a public key not among the authorized |
2620 | keys (see @code{--authorize} below.) | |
554f26ec | 2621 | |
87236aed LC |
2622 | @item --missing |
2623 | Read a list of store file names from the standard input, one per line, | |
2624 | and write on the standard output the subset of these files missing from | |
2625 | the store. | |
2626 | ||
554f26ec | 2627 | @item --generate-key[=@var{parameters}] |
f82cc5fd | 2628 | @cindex signing, archives |
f97c9175 | 2629 | Generate a new key pair for the daemon. This is a prerequisite before |
554f26ec LC |
2630 | archives can be exported with @code{--export}. Note that this operation |
2631 | usually takes time, because it needs to gather enough entropy to | |
2632 | generate the key pair. | |
2633 | ||
2634 | The generated key pair is typically stored under @file{/etc/guix}, in | |
2635 | @file{signing-key.pub} (public key) and @file{signing-key.sec} (private | |
867d8473 LC |
2636 | key, which must be kept secret.) When @var{parameters} is omitted, |
2637 | an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt | |
2638 | versions before 1.6.0, it is a 4096-bit RSA key. | |
f97c9175 | 2639 | Alternatively, @var{parameters} can specify |
554f26ec LC |
2640 | @code{genkey} parameters suitable for Libgcrypt (@pxref{General |
2641 | public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The | |
2642 | Libgcrypt Reference Manual}). | |
f82cc5fd LC |
2643 | |
2644 | @item --authorize | |
2645 | @cindex authorizing, archives | |
2646 | Authorize imports signed by the public key passed on standard input. | |
2647 | The public key must be in ``s-expression advanced format''---i.e., the | |
2648 | same format as the @file{signing-key.pub} file. | |
2649 | ||
2650 | The list of authorized keys is kept in the human-editable file | |
2651 | @file{/etc/guix/acl}. The file contains | |
2652 | @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format | |
2653 | s-expressions''} and is structured as an access-control list in the | |
2654 | @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure | |
2655 | (SPKI)}. | |
c6f8e9dd LC |
2656 | |
2657 | @item --extract=@var{directory} | |
2658 | @itemx -x @var{directory} | |
2659 | Read a single-item archive as served by substitute servers | |
2660 | (@pxref{Substitutes}) and extract it to @var{directory}. This is a | |
2661 | low-level operation needed in only very narrow use cases; see below. | |
2662 | ||
2663 | For example, the following command extracts the substitute for Emacs | |
2664 | served by @code{hydra.gnu.org} to @file{/tmp/emacs}: | |
2665 | ||
2666 | @example | |
2667 | $ wget -O - \ | |
df061d07 | 2668 | https://hydra.gnu.org/nar/@dots{}-emacs-24.5 \ |
c6f8e9dd LC |
2669 | | bunzip2 | guix archive -x /tmp/emacs |
2670 | @end example | |
2671 | ||
2672 | Single-item archives are different from multiple-item archives produced | |
2673 | by @command{guix archive --export}; they contain a single store item, | |
2674 | and they do @emph{not} embed a signature. Thus this operation does | |
2675 | @emph{no} signature verification and its output should be considered | |
2676 | unsafe. | |
2677 | ||
2678 | The primary purpose of this operation is to facilitate inspection of | |
2679 | archive contents coming from possibly untrusted substitute servers. | |
2680 | ||
760c60d6 LC |
2681 | @end table |
2682 | ||
568717fd LC |
2683 | @c ********************************************************************* |
2684 | @node Programming Interface | |
2685 | @chapter Programming Interface | |
2686 | ||
3dc1970d LC |
2687 | GNU Guix provides several Scheme programming interfaces (APIs) to |
2688 | define, build, and query packages. The first interface allows users to | |
2689 | write high-level package definitions. These definitions refer to | |
2690 | familiar packaging concepts, such as the name and version of a package, | |
2691 | its build system, and its dependencies. These definitions can then be | |
2692 | turned into concrete build actions. | |
2693 | ||
ba55b1cb | 2694 | Build actions are performed by the Guix daemon, on behalf of users. In a |
3dc1970d | 2695 | standard setup, the daemon has write access to the store---the |
834129e0 | 2696 | @file{/gnu/store} directory---whereas users do not. The recommended |
3dc1970d LC |
2697 | setup also has the daemon perform builds in chroots, under a specific |
2698 | build users, to minimize interference with the rest of the system. | |
2699 | ||
2700 | @cindex derivation | |
2701 | Lower-level APIs are available to interact with the daemon and the | |
2702 | store. To instruct the daemon to perform a build action, users actually | |
2703 | provide it with a @dfn{derivation}. A derivation is a low-level | |
2704 | representation of the build actions to be taken, and the environment in | |
2705 | which they should occur---derivations are to package definitions what | |
49ad317a LC |
2706 | assembly is to C programs. The term ``derivation'' comes from the fact |
2707 | that build results @emph{derive} from them. | |
3dc1970d LC |
2708 | |
2709 | This chapter describes all these APIs in turn, starting from high-level | |
2710 | package definitions. | |
2711 | ||
568717fd | 2712 | @menu |
b860f382 | 2713 | * Defining Packages:: Defining new packages. |
7458bd0a | 2714 | * Build Systems:: Specifying how packages are built. |
b860f382 LC |
2715 | * The Store:: Manipulating the package store. |
2716 | * Derivations:: Low-level interface to package derivations. | |
2717 | * The Store Monad:: Purely functional interface to the store. | |
21b679f6 | 2718 | * G-Expressions:: Manipulating build expressions. |
568717fd LC |
2719 | @end menu |
2720 | ||
2721 | @node Defining Packages | |
2722 | @section Defining Packages | |
2723 | ||
3dc1970d LC |
2724 | The high-level interface to package definitions is implemented in the |
2725 | @code{(guix packages)} and @code{(guix build-system)} modules. As an | |
2726 | example, the package definition, or @dfn{recipe}, for the GNU Hello | |
2727 | package looks like this: | |
2728 | ||
2729 | @example | |
e7f34eb0 LC |
2730 | (define-module (gnu packages hello) |
2731 | #:use-module (guix packages) | |
2732 | #:use-module (guix download) | |
2733 | #:use-module (guix build-system gnu) | |
a6dcdcac SB |
2734 | #:use-module (guix licenses) |
2735 | #:use-module (gnu packages gawk)) | |
b22a12fd | 2736 | |
79f5dd59 | 2737 | (define-public hello |
3dc1970d LC |
2738 | (package |
2739 | (name "hello") | |
17d8e33f | 2740 | (version "2.10") |
3dc1970d | 2741 | (source (origin |
17d8e33f ML |
2742 | (method url-fetch) |
2743 | (uri (string-append "mirror://gnu/hello/hello-" version | |
2744 | ".tar.gz")) | |
2745 | (sha256 | |
2746 | (base32 | |
2747 | "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))) | |
3dc1970d | 2748 | (build-system gnu-build-system) |
654c0d97 | 2749 | (arguments '(#:configure-flags '("--enable-silent-rules"))) |
3dc1970d | 2750 | (inputs `(("gawk" ,gawk))) |
7458bd0a LC |
2751 | (synopsis "Hello, GNU world: An example GNU package") |
2752 | (description "Guess what GNU Hello prints!") | |
3dc1970d | 2753 | (home-page "http://www.gnu.org/software/hello/") |
b22a12fd | 2754 | (license gpl3+))) |
3dc1970d LC |
2755 | @end example |
2756 | ||
2757 | @noindent | |
2758 | Without being a Scheme expert, the reader may have guessed the meaning | |
f97c9175 AE |
2759 | of the various fields here. This expression binds the variable |
2760 | @code{hello} to a @code{<package>} object, which is essentially a record | |
3dc1970d LC |
2761 | (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}). |
2762 | This package object can be inspected using procedures found in the | |
2763 | @code{(guix packages)} module; for instance, @code{(package-name hello)} | |
2764 | returns---surprise!---@code{"hello"}. | |
2765 | ||
2f7d2d91 LC |
2766 | With luck, you may be able to import part or all of the definition of |
2767 | the package you are interested in from another repository, using the | |
2768 | @code{guix import} command (@pxref{Invoking guix import}). | |
2769 | ||
f97c9175 | 2770 | In the example above, @var{hello} is defined in a module of its own, |
e7f34eb0 LC |
2771 | @code{(gnu packages hello)}. Technically, this is not strictly |
2772 | necessary, but it is convenient to do so: all the packages defined in | |
2773 | modules under @code{(gnu packages @dots{})} are automatically known to | |
2774 | the command-line tools (@pxref{Package Modules}). | |
2775 | ||
3dc1970d LC |
2776 | There are a few points worth noting in the above package definition: |
2777 | ||
2778 | @itemize | |
2779 | @item | |
a2bf4907 LC |
2780 | The @code{source} field of the package is an @code{<origin>} object |
2781 | (@pxref{origin Reference}, for the complete reference). | |
3dc1970d LC |
2782 | Here, the @code{url-fetch} method from @code{(guix download)} is used, |
2783 | meaning that the source is a file to be downloaded over FTP or HTTP. | |
2784 | ||
2785 | The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of | |
2786 | the GNU mirrors defined in @code{(guix download)}. | |
2787 | ||
2788 | The @code{sha256} field specifies the expected SHA256 hash of the file | |
2789 | being downloaded. It is mandatory, and allows Guix to check the | |
2790 | integrity of the file. The @code{(base32 @dots{})} form introduces the | |
6c365eca | 2791 | base32 representation of the hash. You can obtain this information with |
210cc920 LC |
2792 | @code{guix download} (@pxref{Invoking guix download}) and @code{guix |
2793 | hash} (@pxref{Invoking guix hash}). | |
3dc1970d | 2794 | |
f9cc8971 LC |
2795 | @cindex patches |
2796 | When needed, the @code{origin} form can also have a @code{patches} field | |
2797 | listing patches to be applied, and a @code{snippet} field giving a | |
2798 | Scheme expression to modify the source code. | |
2799 | ||
3dc1970d LC |
2800 | @item |
2801 | @cindex GNU Build System | |
7458bd0a LC |
2802 | The @code{build-system} field specifies the procedure to build the |
2803 | package (@pxref{Build Systems}). Here, @var{gnu-build-system} | |
2804 | represents the familiar GNU Build System, where packages may be | |
2805 | configured, built, and installed with the usual @code{./configure && | |
2806 | make && make check && make install} command sequence. | |
2807 | ||
2808 | @item | |
2809 | The @code{arguments} field specifies options for the build system | |
2810 | (@pxref{Build Systems}). Here it is interpreted by | |
2811 | @var{gnu-build-system} as a request run @file{configure} with the | |
2812 | @code{--enable-silent-rules} flag. | |
3dc1970d | 2813 | |
654c0d97 LC |
2814 | @cindex quote |
2815 | @cindex quoting | |
2816 | @findex ' | |
2817 | @findex quote | |
2818 | What about these quote (@code{'}) characters? They are Scheme syntax to | |
2819 | introduce a literal list; @code{'} is synonymous with @code{quote}. | |
2820 | @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual}, | |
2821 | for details. Here the value of the @code{arguments} field is a list of | |
2822 | arguments passed to the build system down the road, as with @code{apply} | |
2823 | (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference | |
2824 | Manual}). | |
2825 | ||
2826 | The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword} | |
2827 | (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and | |
2828 | @code{#:configure-flags} is a keyword used to pass a keyword argument | |
2829 | to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile | |
2830 | Reference Manual}). | |
2831 | ||
3dc1970d LC |
2832 | @item |
2833 | The @code{inputs} field specifies inputs to the build process---i.e., | |
2834 | build-time or run-time dependencies of the package. Here, we define an | |
2835 | input called @code{"gawk"} whose value is that of the @var{gawk} | |
2836 | variable; @var{gawk} is itself bound to a @code{<package>} object. | |
2837 | ||
654c0d97 LC |
2838 | @cindex backquote (quasiquote) |
2839 | @findex ` | |
2840 | @findex quasiquote | |
2841 | @cindex comma (unquote) | |
2842 | @findex , | |
2843 | @findex unquote | |
2844 | @findex ,@@ | |
2845 | @findex unquote-splicing | |
2846 | Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows | |
2847 | us to introduce a literal list in the @code{inputs} field, while | |
2848 | @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a | |
2849 | value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile | |
2850 | Reference Manual}). | |
2851 | ||
3dc1970d LC |
2852 | Note that GCC, Coreutils, Bash, and other essential tools do not need to |
2853 | be specified as inputs here. Instead, @var{gnu-build-system} takes care | |
7458bd0a | 2854 | of ensuring that they are present (@pxref{Build Systems}). |
3dc1970d LC |
2855 | |
2856 | However, any other dependencies need to be specified in the | |
2857 | @code{inputs} field. Any dependency not specified here will simply be | |
2858 | unavailable to the build process, possibly leading to a build failure. | |
2859 | @end itemize | |
2860 | ||
87eafdbd TUBK |
2861 | @xref{package Reference}, for a full description of possible fields. |
2862 | ||
2f7d2d91 | 2863 | Once a package definition is in place, the |
e49951eb | 2864 | package may actually be built using the @code{guix build} command-line |
39bee8a2 LC |
2865 | tool (@pxref{Invoking guix build}). You can easily jump back to the |
2866 | package definition using the @command{guix edit} command | |
2867 | (@pxref{Invoking guix edit}). | |
2868 | @xref{Packaging Guidelines}, for | |
b4f5e0e8 CR |
2869 | more information on how to test package definitions, and |
2870 | @ref{Invoking guix lint}, for information on how to check a definition | |
2871 | for style conformance. | |
2872 | ||
f97c9175 | 2873 | Finally, updating the package definition to a new upstream version |
7458bd0a LC |
2874 | can be partly automated by the @command{guix refresh} command |
2875 | (@pxref{Invoking guix refresh}). | |
3dc1970d LC |
2876 | |
2877 | Behind the scenes, a derivation corresponding to the @code{<package>} | |
2878 | object is first computed by the @code{package-derivation} procedure. | |
834129e0 | 2879 | That derivation is stored in a @code{.drv} file under @file{/gnu/store}. |
ba55b1cb | 2880 | The build actions it prescribes may then be realized by using the |
3dc1970d LC |
2881 | @code{build-derivations} procedure (@pxref{The Store}). |
2882 | ||
2883 | @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}] | |
59688fc4 LC |
2884 | Return the @code{<derivation>} object of @var{package} for @var{system} |
2885 | (@pxref{Derivations}). | |
3dc1970d LC |
2886 | |
2887 | @var{package} must be a valid @code{<package>} object, and @var{system} | |
2888 | must be a string denoting the target system type---e.g., | |
2889 | @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store} | |
2890 | must be a connection to the daemon, which operates on the store | |
2891 | (@pxref{The Store}). | |
2892 | @end deffn | |
568717fd | 2893 | |
9c1edabd LC |
2894 | @noindent |
2895 | @cindex cross-compilation | |
2896 | Similarly, it is possible to compute a derivation that cross-builds a | |
2897 | package for some other system: | |
2898 | ||
2899 | @deffn {Scheme Procedure} package-cross-derivation @var{store} @ | |
2900 | @var{package} @var{target} [@var{system}] | |
59688fc4 LC |
2901 | Return the @code{<derivation>} object of @var{package} cross-built from |
2902 | @var{system} to @var{target}. | |
9c1edabd LC |
2903 | |
2904 | @var{target} must be a valid GNU triplet denoting the target hardware | |
2905 | and operating system, such as @code{"mips64el-linux-gnu"} | |
2906 | (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU | |
2907 | Configure and Build System}). | |
2908 | @end deffn | |
2909 | ||
2a75b0b6 LC |
2910 | @cindex package transformations |
2911 | @cindex input rewriting | |
2912 | @cindex dependency tree rewriting | |
2913 | Packages can be manipulated in arbitrary ways. An example of a useful | |
2914 | transformation is @dfn{input rewriting}, whereby the dependency tree of | |
2915 | a package is rewritten by replacing specific inputs by others: | |
2916 | ||
2917 | @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @ | |
2918 | [@var{rewrite-name}] | |
2919 | Return a procedure that, when passed a package, replaces its direct and | |
2920 | indirect dependencies (but not its implicit inputs) according to | |
2921 | @var{replacements}. @var{replacements} is a list of package pairs; the | |
2922 | first element of each pair is the package to replace, and the second one | |
2923 | is the replacement. | |
2924 | ||
2925 | Optionally, @var{rewrite-name} is a one-argument procedure that takes | |
2926 | the name of a package and returns its new name after rewrite. | |
2927 | @end deffn | |
2928 | ||
2929 | @noindent | |
2930 | Consider this example: | |
2931 | ||
2932 | @example | |
2933 | (define libressl-instead-of-openssl | |
2934 | ;; This is a procedure to replace OPENSSL by LIBRESSL, | |
2935 | ;; recursively. | |
2936 | (package-input-rewriting `((,openssl . ,libressl)))) | |
2937 | ||
2938 | (define git-with-libressl | |
2939 | (libressl-instead-of-openssl git)) | |
2940 | @end example | |
2941 | ||
2942 | @noindent | |
2943 | Here we first define a rewriting procedure that replaces @var{openssl} | |
2944 | with @var{libressl}. Then we use it to define a @dfn{variant} of the | |
2945 | @var{git} package that uses @var{libressl} instead of @var{openssl}. | |
2946 | This is exactly what the @option{--with-input} command-line option does | |
2947 | (@pxref{Package Transformation Options, @option{--with-input}}). | |
2948 | ||
f37f2b83 LC |
2949 | A more generic procedure to rewrite a package dependency graph is |
2950 | @code{package-mapping}: it supports arbitrary changes to nodes in the | |
2951 | graph. | |
2952 | ||
2953 | @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] | |
2954 | Return a procedure that, given a package, applies @var{proc} to all the packages | |
2955 | depended on and returns the resulting package. The procedure stops recursion | |
2956 | when @var{cut?} returns true for a given package. | |
2957 | @end deffn | |
2958 | ||
87eafdbd TUBK |
2959 | @menu |
2960 | * package Reference :: The package data type. | |
2961 | * origin Reference:: The origin data type. | |
2962 | @end menu | |
2963 | ||
2964 | ||
2965 | @node package Reference | |
2966 | @subsection @code{package} Reference | |
2967 | ||
2968 | This section summarizes all the options available in @code{package} | |
2969 | declarations (@pxref{Defining Packages}). | |
2970 | ||
2971 | @deftp {Data Type} package | |
2972 | This is the data type representing a package recipe. | |
2973 | ||
2974 | @table @asis | |
2975 | @item @code{name} | |
2976 | The name of the package, as a string. | |
2977 | ||
2978 | @item @code{version} | |
2979 | The version of the package, as a string. | |
2980 | ||
2981 | @item @code{source} | |
da675305 LC |
2982 | An object telling how the source code for the package should be |
2983 | acquired. Most of the time, this is an @code{origin} object, which | |
2984 | denotes a file fetched from the Internet (@pxref{origin Reference}). It | |
2985 | can also be any other ``file-like'' object such as a @code{local-file}, | |
2986 | which denotes a file from the local file system (@pxref{G-Expressions, | |
2987 | @code{local-file}}). | |
87eafdbd TUBK |
2988 | |
2989 | @item @code{build-system} | |
2990 | The build system that should be used to build the package (@pxref{Build | |
2991 | Systems}). | |
2992 | ||
2993 | @item @code{arguments} (default: @code{'()}) | |
2994 | The arguments that should be passed to the build system. This is a | |
2995 | list, typically containing sequential keyword-value pairs. | |
2996 | ||
2997 | @item @code{inputs} (default: @code{'()}) | |
70650c68 LC |
2998 | @itemx @code{native-inputs} (default: @code{'()}) |
2999 | @itemx @code{propagated-inputs} (default: @code{'()}) | |
3000 | @cindex inputs, of packages | |
3001 | These fields list dependencies of the package. Each one is a list of | |
3002 | tuples, where each tuple has a label for the input (a string) as its | |
3003 | first element, a package, origin, or derivation as its second element, | |
3004 | and optionally the name of the output thereof that should be used, which | |
3005 | defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for | |
f97c9175 | 3006 | more on package outputs). For example, the list below specifies three |
70650c68 | 3007 | inputs: |
87eafdbd | 3008 | |
70650c68 LC |
3009 | @example |
3010 | `(("libffi" ,libffi) | |
3011 | ("libunistring" ,libunistring) | |
3012 | ("glib:bin" ,glib "bin")) ;the "bin" output of Glib | |
3013 | @end example | |
3014 | ||
3015 | @cindex cross compilation, package dependencies | |
3016 | The distinction between @code{native-inputs} and @code{inputs} is | |
3017 | necessary when considering cross-compilation. When cross-compiling, | |
3018 | dependencies listed in @code{inputs} are built for the @emph{target} | |
3019 | architecture; conversely, dependencies listed in @code{native-inputs} | |
3020 | are built for the architecture of the @emph{build} machine. | |
3021 | ||
f97c9175 AE |
3022 | @code{native-inputs} is typically used to list tools needed at |
3023 | build time, but not at run time, such as Autoconf, Automake, pkg-config, | |
70650c68 LC |
3024 | Gettext, or Bison. @command{guix lint} can report likely mistakes in |
3025 | this area (@pxref{Invoking guix lint}). | |
3026 | ||
3027 | @anchor{package-propagated-inputs} | |
3028 | Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the | |
f97c9175 AE |
3029 | specified packages will be automatically installed alongside the package |
3030 | they belong to (@pxref{package-cmd-propagated-inputs, @command{guix | |
70650c68 LC |
3031 | package}}, for information on how @command{guix package} deals with |
3032 | propagated inputs.) | |
21461f27 | 3033 | |
e0508b6b LC |
3034 | For example this is necessary when a C/C++ library needs headers of |
3035 | another library to compile, or when a pkg-config file refers to another | |
3036 | one @i{via} its @code{Requires} field. | |
3037 | ||
f97c9175 AE |
3038 | Another example where @code{propagated-inputs} is useful is for languages |
3039 | that lack a facility to record the run-time search path akin to the | |
c8ebb4c4 | 3040 | @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and |
e0508b6b LC |
3041 | more. To ensure that libraries written in those languages can find |
3042 | library code they depend on at run time, run-time dependencies must be | |
3043 | listed in @code{propagated-inputs} rather than @code{inputs}. | |
87eafdbd | 3044 | |
87eafdbd TUBK |
3045 | @item @code{self-native-input?} (default: @code{#f}) |
3046 | This is a Boolean field telling whether the package should use itself as | |
3047 | a native input when cross-compiling. | |
3048 | ||
3049 | @item @code{outputs} (default: @code{'("out")}) | |
3050 | The list of output names of the package. @xref{Packages with Multiple | |
3051 | Outputs}, for typical uses of additional outputs. | |
3052 | ||
3053 | @item @code{native-search-paths} (default: @code{'()}) | |
3054 | @itemx @code{search-paths} (default: @code{'()}) | |
3055 | A list of @code{search-path-specification} objects describing | |
3056 | search-path environment variables honored by the package. | |
3057 | ||
3058 | @item @code{replacement} (default: @code{#f}) | |
f97c9175 | 3059 | This must be either @code{#f} or a package object that will be used as a |
87eafdbd TUBK |
3060 | @dfn{replacement} for this package. @xref{Security Updates, grafts}, |
3061 | for details. | |
3062 | ||
3063 | @item @code{synopsis} | |
3064 | A one-line description of the package. | |
3065 | ||
3066 | @item @code{description} | |
3067 | A more elaborate description of the package. | |
3068 | ||
3069 | @item @code{license} | |
e32171ee | 3070 | @cindex license, of packages |
f97c9175 AE |
3071 | The license of the package; a value from @code{(guix licenses)}, |
3072 | or a list of such values. | |
87eafdbd TUBK |
3073 | |
3074 | @item @code{home-page} | |
3075 | The URL to the home-page of the package, as a string. | |
3076 | ||
3077 | @item @code{supported-systems} (default: @var{%supported-systems}) | |
3078 | The list of systems supported by the package, as strings of the form | |
3079 | @code{architecture-kernel}, for example @code{"x86_64-linux"}. | |
3080 | ||
3081 | @item @code{maintainers} (default: @code{'()}) | |
3082 | The list of maintainers of the package, as @code{maintainer} objects. | |
3083 | ||
3084 | @item @code{location} (default: source location of the @code{package} form) | |
f97c9175 | 3085 | The source location of the package. It is useful to override this when |
87eafdbd TUBK |
3086 | inheriting from another package, in which case this field is not |
3087 | automatically corrected. | |
3088 | @end table | |
3089 | @end deftp | |
3090 | ||
3091 | ||
3092 | @node origin Reference | |
3093 | @subsection @code{origin} Reference | |
3094 | ||
3095 | This section summarizes all the options available in @code{origin} | |
3096 | declarations (@pxref{Defining Packages}). | |
3097 | ||
3098 | @deftp {Data Type} origin | |
3099 | This is the data type representing a source code origin. | |
3100 | ||
3101 | @table @asis | |
3102 | @item @code{uri} | |
3103 | An object containing the URI of the source. The object type depends on | |
3104 | the @code{method} (see below). For example, when using the | |
3105 | @var{url-fetch} method of @code{(guix download)}, the valid @code{uri} | |
3106 | values are: a URL represented as a string, or a list thereof. | |
3107 | ||
3108 | @item @code{method} | |
f97c9175 | 3109 | A procedure that handles the URI. |
87eafdbd TUBK |
3110 | |
3111 | Examples include: | |
3112 | ||
3113 | @table @asis | |
3114 | @item @var{url-fetch} from @code{(guix download)} | |
f97c9175 | 3115 | download a file from the HTTP, HTTPS, or FTP URL specified in the |
87eafdbd TUBK |
3116 | @code{uri} field; |
3117 | ||
db97a03a | 3118 | @vindex git-fetch |
87eafdbd TUBK |
3119 | @item @var{git-fetch} from @code{(guix git-download)} |
3120 | clone the Git version control repository, and check out the revision | |
3121 | specified in the @code{uri} field as a @code{git-reference} object; a | |
3122 | @code{git-reference} looks like this: | |
3123 | ||
3124 | @example | |
3125 | (git-reference | |
3126 | (url "git://git.debian.org/git/pkg-shadow/shadow") | |
3127 | (commit "v4.1.5.1")) | |
3128 | @end example | |
3129 | @end table | |
3130 | ||
3131 | @item @code{sha256} | |
3132 | A bytevector containing the SHA-256 hash of the source. Typically the | |
3133 | @code{base32} form is used here to generate the bytevector from a | |
3134 | base-32 string. | |
3135 | ||
db97a03a LC |
3136 | You can obtain this information using @code{guix download} |
3137 | (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking | |
3138 | guix hash}). | |
3139 | ||
87eafdbd TUBK |
3140 | @item @code{file-name} (default: @code{#f}) |
3141 | The file name under which the source code should be saved. When this is | |
3142 | @code{#f}, a sensible default value will be used in most cases. In case | |
3143 | the source is fetched from a URL, the file name from the URL will be | |
f97c9175 | 3144 | used. For version control checkouts, it is recommended to provide the |
87eafdbd TUBK |
3145 | file name explicitly because the default is not very descriptive. |
3146 | ||
3147 | @item @code{patches} (default: @code{'()}) | |
3148 | A list of file names containing patches to be applied to the source. | |
3149 | ||
0dfebdaa LC |
3150 | This list of patches must be unconditional. In particular, it cannot |
3151 | depend on the value of @code{%current-system} or | |
3152 | @code{%current-target-system}. | |
3153 | ||
87eafdbd | 3154 | @item @code{snippet} (default: @code{#f}) |
1929fdba LC |
3155 | A G-expression (@pxref{G-Expressions}) or S-expression that will be run |
3156 | in the source directory. This is a convenient way to modify the source, | |
3157 | sometimes more convenient than a patch. | |
87eafdbd TUBK |
3158 | |
3159 | @item @code{patch-flags} (default: @code{'("-p1")}) | |
3160 | A list of command-line flags that should be passed to the @code{patch} | |
3161 | command. | |
3162 | ||
3163 | @item @code{patch-inputs} (default: @code{#f}) | |
3164 | Input packages or derivations to the patching process. When this is | |
3165 | @code{#f}, the usual set of inputs necessary for patching are provided, | |
3166 | such as GNU@tie{}Patch. | |
3167 | ||
3168 | @item @code{modules} (default: @code{'()}) | |
3169 | A list of Guile modules that should be loaded during the patching | |
3170 | process and while running the code in the @code{snippet} field. | |
3171 | ||
87eafdbd TUBK |
3172 | @item @code{patch-guile} (default: @code{#f}) |
3173 | The Guile package that should be used in the patching process. When | |
3174 | this is @code{#f}, a sensible default is used. | |
3175 | @end table | |
3176 | @end deftp | |
3177 | ||
9c1edabd | 3178 | |
7458bd0a LC |
3179 | @node Build Systems |
3180 | @section Build Systems | |
3181 | ||
3182 | @cindex build system | |
3183 | Each package definition specifies a @dfn{build system} and arguments for | |
3184 | that build system (@pxref{Defining Packages}). This @code{build-system} | |
f97c9175 | 3185 | field represents the build procedure of the package, as well as implicit |
7458bd0a LC |
3186 | dependencies of that build procedure. |
3187 | ||
3188 | Build systems are @code{<build-system>} objects. The interface to | |
3189 | create and manipulate them is provided by the @code{(guix build-system)} | |
3190 | module, and actual build systems are exported by specific modules. | |
3191 | ||
f5fd4fd2 | 3192 | @cindex bag (low-level package representation) |
0d5a559f LC |
3193 | Under the hood, build systems first compile package objects to |
3194 | @dfn{bags}. A @dfn{bag} is like a package, but with less | |
3195 | ornamentation---in other words, a bag is a lower-level representation of | |
3196 | a package, which includes all the inputs of that package, including some | |
3197 | that were implicitly added by the build system. This intermediate | |
3198 | representation is then compiled to a derivation (@pxref{Derivations}). | |
3199 | ||
7458bd0a LC |
3200 | Build systems accept an optional list of @dfn{arguments}. In package |
3201 | definitions, these are passed @i{via} the @code{arguments} field | |
3202 | (@pxref{Defining Packages}). They are typically keyword arguments | |
3203 | (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU | |
3204 | Guile Reference Manual}). The value of these arguments is usually | |
3205 | evaluated in the @dfn{build stratum}---i.e., by a Guile process launched | |
3206 | by the daemon (@pxref{Derivations}). | |
3207 | ||
3208 | The main build system is @var{gnu-build-system}, which implements the | |
f97c9175 | 3209 | standard build procedure for GNU and many other packages. It |
7458bd0a LC |
3210 | is provided by the @code{(guix build-system gnu)} module. |
3211 | ||
3212 | @defvr {Scheme Variable} gnu-build-system | |
3213 | @var{gnu-build-system} represents the GNU Build System, and variants | |
3214 | thereof (@pxref{Configuration, configuration and makefile conventions,, | |
3215 | standards, GNU Coding Standards}). | |
3216 | ||
3217 | @cindex build phases | |
f97c9175 | 3218 | In a nutshell, packages using it are configured, built, and installed with |
7458bd0a LC |
3219 | the usual @code{./configure && make && make check && make install} |
3220 | command sequence. In practice, a few additional steps are often needed. | |
3221 | All these steps are split up in separate @dfn{phases}, | |
3222 | notably@footnote{Please see the @code{(guix build gnu-build-system)} | |
3223 | modules for more details about the build phases.}: | |
3224 | ||
3225 | @table @code | |
3226 | @item unpack | |
3227 | Unpack the source tarball, and change the current directory to the | |
3228 | extracted source tree. If the source is actually a directory, copy it | |
3229 | to the build tree, and enter that directory. | |
3230 | ||
3231 | @item patch-source-shebangs | |
3232 | Patch shebangs encountered in source files so they refer to the right | |
3233 | store file names. For instance, this changes @code{#!/bin/sh} to | |
3234 | @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}. | |
3235 | ||
3236 | @item configure | |
3237 | Run the @file{configure} script with a number of default options, such | |
3238 | as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified | |
3239 | by the @code{#:configure-flags} argument. | |
3240 | ||
3241 | @item build | |
3242 | Run @code{make} with the list of flags specified with | |
0917e80e | 3243 | @code{#:make-flags}. If the @code{#:parallel-build?} argument is true |
7458bd0a LC |
3244 | (the default), build with @code{make -j}. |
3245 | ||
3246 | @item check | |
3247 | Run @code{make check}, or some other target specified with | |
3248 | @code{#:test-target}, unless @code{#:tests? #f} is passed. If the | |
3249 | @code{#:parallel-tests?} argument is true (the default), run @code{make | |
3250 | check -j}. | |
3251 | ||
3252 | @item install | |
3253 | Run @code{make install} with the flags listed in @code{#:make-flags}. | |
3254 | ||
3255 | @item patch-shebangs | |
3256 | Patch shebangs on the installed executable files. | |
3257 | ||
3258 | @item strip | |
3259 | Strip debugging symbols from ELF files (unless @code{#:strip-binaries?} | |
3260 | is false), copying them to the @code{debug} output when available | |
3261 | (@pxref{Installing Debugging Files}). | |
3262 | @end table | |
3263 | ||
3264 | @vindex %standard-phases | |
3265 | The build-side module @code{(guix build gnu-build-system)} defines | |
3266 | @var{%standard-phases} as the default list of build phases. | |
3267 | @var{%standard-phases} is a list of symbol/procedure pairs, where the | |
3268 | procedure implements the actual phase. | |
3269 | ||
3270 | The list of phases used for a particular package can be changed with the | |
3271 | @code{#:phases} parameter. For instance, passing: | |
3272 | ||
3273 | @example | |
c2c5dc79 | 3274 | #:phases (modify-phases %standard-phases (delete 'configure)) |
7458bd0a LC |
3275 | @end example |
3276 | ||
9bf404e9 | 3277 | means that all the phases described above will be used, except the |
7458bd0a LC |
3278 | @code{configure} phase. |
3279 | ||
3280 | In addition, this build system ensures that the ``standard'' environment | |
3281 | for GNU packages is available. This includes tools such as GCC, libc, | |
3282 | Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix | |
f97c9175 AE |
3283 | build-system gnu)} module for a complete list). We call these the |
3284 | @dfn{implicit inputs} of a package, because package definitions do not | |
7458bd0a LC |
3285 | have to mention them. |
3286 | @end defvr | |
3287 | ||
3288 | Other @code{<build-system>} objects are defined to support other | |
3289 | conventions and tools used by free software packages. They inherit most | |
3290 | of @var{gnu-build-system}, and differ mainly in the set of inputs | |
3291 | implicitly added to the build process, and in the list of phases | |
3292 | executed. Some of these build systems are listed below. | |
3293 | ||
5f7a1a4d RW |
3294 | @defvr {Scheme Variable} ant-build-system |
3295 | This variable is exported by @code{(guix build-system ant)}. It | |
3296 | implements the build procedure for Java packages that can be built with | |
3297 | @url{http://ant.apache.org/, Ant build tool}. | |
3298 | ||
3299 | It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as | |
3300 | provided by the @code{icedtea} package to the set of inputs. Different | |
3301 | packages can be specified with the @code{#:ant} and @code{#:jdk} | |
3302 | parameters, respectively. | |
3303 | ||
3304 | When the original package does not provide a suitable Ant build file, | |
3305 | the parameter @code{#:jar-name} can be used to generate a minimal Ant | |
3306 | build file @file{build.xml} with tasks to build the specified jar | |
3307 | archive. | |
3308 | ||
3309 | The parameter @code{#:build-target} can be used to specify the Ant task | |
3310 | that should be run during the @code{build} phase. By default the | |
3311 | ``jar'' task will be run. | |
3312 | ||
3313 | @end defvr | |
3314 | ||
a1b30f99 AP |
3315 | @defvr {Scheme Variable} asdf-build-system/source |
3316 | @defvrx {Scheme Variable} asdf-build-system/sbcl | |
3317 | @defvrx {Scheme Variable} asdf-build-system/ecl | |
3318 | ||
3319 | These variables, exported by @code{(guix build-system asdf)}, implement | |
3320 | build procedures for Common Lisp packages using | |
3321 | @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system | |
3322 | definition facility for Common Lisp programs and libraries. | |
3323 | ||
3324 | The @code{asdf-build-system/source} system installs the packages in | |
3325 | source form, and can be loaded using any common lisp implementation, via | |
3326 | ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary | |
3327 | systems in the format which a particular implementation understands. | |
3328 | These build systems can also be used to produce executable programs, or | |
3329 | lisp images which contain a set of packages pre-loaded. | |
3330 | ||
3331 | The build system uses naming conventions. For binary packages, the | |
3332 | package itself as well as its run-time dependencies should begin their | |
3333 | name with the lisp implementation, such as @code{sbcl-} for | |
3334 | @code{asdf-build-system/sbcl}. Beginning the input name with this | |
3335 | prefix will allow the build system to encode its location into the | |
3336 | resulting library, so that the input can be found at run-time. | |
3337 | ||
3338 | If dependencies are used only for tests, it is convenient to use a | |
3339 | different prefix in order to avoid having a run-time dependency on such | |
3340 | systems. For example, | |
3341 | ||
3342 | @example | |
3343 | (define-public sbcl-bordeaux-threads | |
3344 | (package | |
3345 | ... | |
3346 | (native-inputs `(("tests:cl-fiveam" ,sbcl-fiveam))) | |
3347 | ...)) | |
3348 | @end example | |
3349 | ||
3350 | Additionally, the corresponding source package should be labeled using | |
3351 | the same convention as python packages (see @ref{Python Modules}), using | |
3352 | the @code{cl-} prefix. | |
3353 | ||
3354 | For binary packages, each system should be defined as a Guix package. | |
3355 | If one package @code{origin} contains several systems, package variants | |
3356 | can be created in order to build all the systems. Source packages, | |
3357 | which use @code{asdf-build-system/source}, may contain several systems. | |
3358 | ||
3359 | In order to create executable programs and images, the build-side | |
3360 | procedures @code{build-program} and @code{build-image} can be used. | |
3361 | They should be called in a build phase after the @code{create-symlinks} | |
3362 | phase, so that the system which was just built can be used within the | |
3363 | resulting image. @code{build-program} requires a list of Common Lisp | |
3364 | expressions to be passed as the @code{#:entry-program} argument. | |
3365 | ||
3366 | If the system is not defined within its own @code{.asd} file of the same | |
3367 | name, then the @code{#:asd-file} parameter should be used to specify | |
3368 | which file the system is defined in. | |
3369 | ||
3370 | @end defvr | |
3371 | ||
1ec34dd7 LC |
3372 | @defvr {Scheme Variable} cargo-build-system |
3373 | @cindex Rust programming language | |
3374 | @cindex Cargo (Rust build system) | |
3375 | This variable is exported by @code{(guix build-system cargo)}. It | |
3376 | supports builds of packages using Cargo, the build tool of the | |
3377 | @uref{https://www.rust-lang.org, Rust programming language}. | |
3378 | ||
3379 | In its @code{configure} phase, this build system replaces dependencies | |
3380 | specified in the @file{Carto.toml} file with inputs to the Guix package. | |
3381 | The @code{install} phase installs the binaries, and it also installs the | |
3382 | source code and @file{Cargo.toml} file. | |
3383 | @end defvr | |
3384 | ||
7458bd0a LC |
3385 | @defvr {Scheme Variable} cmake-build-system |
3386 | This variable is exported by @code{(guix build-system cmake)}. It | |
3387 | implements the build procedure for packages using the | |
3388 | @url{http://www.cmake.org, CMake build tool}. | |
3389 | ||
3390 | It automatically adds the @code{cmake} package to the set of inputs. | |
3391 | Which package is used can be specified with the @code{#:cmake} | |
3392 | parameter. | |
9849cfc1 LC |
3393 | |
3394 | The @code{#:configure-flags} parameter is taken as a list of flags | |
3395 | passed to the @command{cmake} command. The @code{#:build-type} | |
3396 | parameter specifies in abstract terms the flags passed to the compiler; | |
3397 | it defaults to @code{"RelWithDebInfo"} (short for ``release mode with | |
3398 | debugging information''), which roughly means that code is compiled with | |
3399 | @code{-O2 -g}, as is the case for Autoconf-based packages by default. | |
7458bd0a LC |
3400 | @end defvr |
3401 | ||
3afcf52b FB |
3402 | @defvr {Scheme Variable} glib-or-gtk-build-system |
3403 | This variable is exported by @code{(guix build-system glib-or-gtk)}. It | |
3404 | is intended for use with packages making use of GLib or GTK+. | |
3405 | ||
3406 | This build system adds the following two phases to the ones defined by | |
3407 | @var{gnu-build-system}: | |
3408 | ||
3409 | @table @code | |
3410 | @item glib-or-gtk-wrap | |
f97c9175 AE |
3411 | The phase @code{glib-or-gtk-wrap} ensures that programs in |
3412 | @file{bin/} are able to find GLib ``schemas'' and | |
3afcf52b FB |
3413 | @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+ |
3414 | modules}. This is achieved by wrapping the programs in launch scripts | |
3415 | that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH} | |
3416 | environment variables. | |
3417 | ||
73aa8ddb LC |
3418 | It is possible to exclude specific package outputs from that wrapping |
3419 | process by listing their names in the | |
3420 | @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful | |
3421 | when an output is known not to contain any GLib or GTK+ binaries, and | |
3422 | where wrapping would gratuitously add a dependency of that output on | |
3423 | GLib and GTK+. | |
3424 | ||
3afcf52b | 3425 | @item glib-or-gtk-compile-schemas |
f97c9175 | 3426 | The phase @code{glib-or-gtk-compile-schemas} makes sure that all |
3afcf52b | 3427 | @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html, |
f97c9175 | 3428 | GSettings schemas} of GLib are compiled. Compilation is performed by the |
3afcf52b FB |
3429 | @command{glib-compile-schemas} program. It is provided by the package |
3430 | @code{glib:bin} which is automatically imported by the build system. | |
3431 | The @code{glib} package providing @command{glib-compile-schemas} can be | |
3432 | specified with the @code{#:glib} parameter. | |
3433 | @end table | |
3434 | ||
3435 | Both phases are executed after the @code{install} phase. | |
3436 | @end defvr | |
3437 | ||
3184f14a | 3438 | @defvr {Scheme Variable} ocaml-build-system |
9fc221b5 | 3439 | This variable is exported by @code{(guix build-system ocaml)}. It implements |
3184f14a JL |
3440 | a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists |
3441 | of choosing the correct set of commands to run for each package. OCaml | |
3442 | packages can expect many different commands to be run. This build system will | |
3443 | try some of them. | |
3444 | ||
3445 | When the package has a @file{setup.ml} file present at the top-level, it will | |
3446 | run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and | |
3447 | @code{ocaml setup.ml -install}. The build system will assume that this file | |
3448 | was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take | |
3449 | care of setting the prefix and enabling tests if they are not disabled. You | |
3450 | can pass configure and build flags with the @code{#:configure-flags} and | |
3451 | @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the | |
3452 | set of flags used to enable tests. The @code{#:use-make?} key can be used to | |
3453 | bypass this system in the build and install phases. | |
3454 | ||
3455 | When the package has a @file{configure} file, it is assumed that it is a | |
3456 | hand-made configure script that requires a different argument format than | |
3457 | in the @code{gnu-build-system}. You can add more flags with the | |
3458 | @code{#:configure-flags} key. | |
3459 | ||
3460 | When the package has a @file{Makefile} file (or @code{#:use-make?} is | |
3461 | @code{#t}), it will be used and more flags can be passed to the build and | |
3462 | install phases with the @code{#:make-flags} key. | |
3463 | ||
3464 | Finally, some packages do not have these files and use a somewhat standard | |
3465 | location for its build system. In that case, the build system will run | |
3466 | @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of | |
3467 | providing the path to the required findlib module. Additional flags can | |
3468 | be passed via the @code{#:build-flags} key. Install is taken care of by | |
3469 | @command{opam-installer}. In this case, the @code{opam} package must | |
3470 | be added to the @code{native-inputs} field of the package definition. | |
3471 | ||
3472 | Note that most OCaml packages assume they will be installed in the same | |
88ba7852 | 3473 | directory as OCaml, which is not what we want in guix. In particular, they |
3184f14a | 3474 | will install @file{.so} files in their module's directory, which is usually |
88ba7852 | 3475 | fine because it is in the OCaml compiler directory. In guix though, these |
3184f14a JL |
3476 | libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This |
3477 | variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where | |
3478 | @file{.so} libraries should be installed. | |
3479 | @end defvr | |
3480 | ||
7458bd0a LC |
3481 | @defvr {Scheme Variable} python-build-system |
3482 | This variable is exported by @code{(guix build-system python)}. It | |
3483 | implements the more or less standard build procedure used by Python | |
3484 | packages, which consists in running @code{python setup.py build} and | |
3485 | then @code{python setup.py install --prefix=/gnu/store/@dots{}}. | |
3486 | ||
3487 | For packages that install stand-alone Python programs under @code{bin/}, | |
f97c9175 | 3488 | it takes care of wrapping these programs so that their @code{PYTHONPATH} |
7458bd0a LC |
3489 | environment variable points to all the Python libraries they depend on. |
3490 | ||
8a46205b CM |
3491 | Which Python package is used to perform the build can be specified with |
3492 | the @code{#:python} parameter. This is a useful way to force a package | |
3493 | to be built for a specific version of the Python interpreter, which | |
3494 | might be necessary if the package is only compatible with a single | |
3495 | interpreter version. | |
5f7565d1 HG |
3496 | |
3497 | By default guix calls @code{setup.py} under control of | |
3498 | @code{setuptools}, much like @command{pip} does. Some packages are not | |
3499 | compatible with setuptools (and pip), thus you can disable this by | |
3500 | setting the @code{#:use-setuptools} parameter to @code{#f}. | |
7458bd0a LC |
3501 | @end defvr |
3502 | ||
3503 | @defvr {Scheme Variable} perl-build-system | |
3504 | This variable is exported by @code{(guix build-system perl)}. It | |
2d2a53fc EB |
3505 | implements the standard build procedure for Perl packages, which either |
3506 | consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}}, | |
3507 | followed by @code{Build} and @code{Build install}; or in running | |
3508 | @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by | |
f97c9175 | 3509 | @code{make} and @code{make install}, depending on which of |
2d2a53fc EB |
3510 | @code{Build.PL} or @code{Makefile.PL} is present in the package |
3511 | distribution. Preference is given to the former if both @code{Build.PL} | |
3512 | and @code{Makefile.PL} exist in the package distribution. This | |
3513 | preference can be reversed by specifying @code{#t} for the | |
3514 | @code{#:make-maker?} parameter. | |
3515 | ||
3516 | The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation | |
3517 | passes flags specified by the @code{#:make-maker-flags} or | |
3518 | @code{#:module-build-flags} parameter, respectively. | |
7458bd0a LC |
3519 | |
3520 | Which Perl package is used can be specified with @code{#:perl}. | |
3521 | @end defvr | |
3522 | ||
f8f3bef6 RW |
3523 | @defvr {Scheme Variable} r-build-system |
3524 | This variable is exported by @code{(guix build-system r)}. It | |
3525 | implements the build procedure used by @uref{http://r-project.org, R} | |
3526 | packages, which essentially is little more than running @code{R CMD | |
3527 | INSTALL --library=/gnu/store/@dots{}} in an environment where | |
3528 | @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests | |
3529 | are run after installation using the R function | |
3530 | @code{tools::testInstalledPackage}. | |
3531 | @end defvr | |
3532 | ||
c08f9818 DT |
3533 | @defvr {Scheme Variable} ruby-build-system |
3534 | This variable is exported by @code{(guix build-system ruby)}. It | |
3535 | implements the RubyGems build procedure used by Ruby packages, which | |
3536 | involves running @code{gem build} followed by @code{gem install}. | |
3537 | ||
5dc87623 DT |
3538 | The @code{source} field of a package that uses this build system |
3539 | typically references a gem archive, since this is the format that Ruby | |
3540 | developers use when releasing their software. The build system unpacks | |
3541 | the gem archive, potentially patches the source, runs the test suite, | |
3542 | repackages the gem, and installs it. Additionally, directories and | |
3543 | tarballs may be referenced to allow building unreleased gems from Git or | |
3544 | a traditional source release tarball. | |
e83c6d00 | 3545 | |
c08f9818 | 3546 | Which Ruby package is used can be specified with the @code{#:ruby} |
6e9f2913 PP |
3547 | parameter. A list of additional flags to be passed to the @command{gem} |
3548 | command can be specified with the @code{#:gem-flags} parameter. | |
c08f9818 | 3549 | @end defvr |
7458bd0a | 3550 | |
a677c726 RW |
3551 | @defvr {Scheme Variable} waf-build-system |
3552 | This variable is exported by @code{(guix build-system waf)}. It | |
3553 | implements a build procedure around the @code{waf} script. The common | |
3554 | phases---@code{configure}, @code{build}, and @code{install}---are | |
3555 | implemented by passing their names as arguments to the @code{waf} | |
3556 | script. | |
3557 | ||
3558 | The @code{waf} script is executed by the Python interpreter. Which | |
3559 | Python package is used to run the script can be specified with the | |
3560 | @code{#:python} parameter. | |
3561 | @end defvr | |
3562 | ||
14dfdf2e FB |
3563 | @defvr {Scheme Variable} haskell-build-system |
3564 | This variable is exported by @code{(guix build-system haskell)}. It | |
3565 | implements the Cabal build procedure used by Haskell packages, which | |
3566 | involves running @code{runhaskell Setup.hs configure | |
3567 | --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}. | |
3568 | Instead of installing the package by running @code{runhaskell Setup.hs | |
3569 | install}, to avoid trying to register libraries in the read-only | |
3570 | compiler store directory, the build system uses @code{runhaskell | |
3571 | Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In | |
3572 | addition, the build system generates the package documentation by | |
3573 | running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f} | |
3574 | is passed. Optional Haddock parameters can be passed with the help of | |
3575 | the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is | |
3576 | not found, the build system looks for @code{Setup.lhs} instead. | |
3577 | ||
3578 | Which Haskell compiler is used can be specified with the @code{#:haskell} | |
a54bd6d7 | 3579 | parameter which defaults to @code{ghc}. |
14dfdf2e FB |
3580 | @end defvr |
3581 | ||
65e862d1 DM |
3582 | @defvr {Scheme Variable} dub-build-system |
3583 | This variable is exported by @code{(guix build-system dub)}. It | |
3584 | implements the Dub build procedure used by D packages, which | |
3585 | involves running @code{dub build} and @code{dub run}. | |
3586 | Installation is done by copying the files manually. | |
3587 | ||
3588 | Which D compiler is used can be specified with the @code{#:ldc} | |
3589 | parameter which defaults to @code{ldc}. | |
3590 | @end defvr | |
3591 | ||
e9137a53 FB |
3592 | @defvr {Scheme Variable} emacs-build-system |
3593 | This variable is exported by @code{(guix build-system emacs)}. It | |
f97c9175 AE |
3594 | implements an installation procedure similar to the packaging system |
3595 | of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}). | |
e9137a53 FB |
3596 | |
3597 | It first creates the @code{@var{package}-autoloads.el} file, then it | |
3598 | byte compiles all Emacs Lisp files. Differently from the Emacs | |
3599 | packaging system, the Info documentation files are moved to the standard | |
3600 | documentation directory and the @file{dir} file is deleted. Each | |
3601 | package is installed in its own directory under | |
3602 | @file{share/emacs/site-lisp/guix.d}. | |
3603 | @end defvr | |
3604 | ||
7458bd0a LC |
3605 | Lastly, for packages that do not need anything as sophisticated, a |
3606 | ``trivial'' build system is provided. It is trivial in the sense that | |
3607 | it provides basically no support: it does not pull any implicit inputs, | |
3608 | and does not have a notion of build phases. | |
3609 | ||
3610 | @defvr {Scheme Variable} trivial-build-system | |
3611 | This variable is exported by @code{(guix build-system trivial)}. | |
3612 | ||
3613 | This build system requires a @code{#:builder} argument. This argument | |
f97c9175 | 3614 | must be a Scheme expression that builds the package output(s)---as |
7458bd0a LC |
3615 | with @code{build-expression->derivation} (@pxref{Derivations, |
3616 | @code{build-expression->derivation}}). | |
3617 | @end defvr | |
3618 | ||
568717fd LC |
3619 | @node The Store |
3620 | @section The Store | |
3621 | ||
e531ac2a | 3622 | @cindex store |
1ddee424 | 3623 | @cindex store items |
e531ac2a LC |
3624 | @cindex store paths |
3625 | ||
f97c9175 AE |
3626 | Conceptually, the @dfn{store} is the place where derivations that have |
3627 | been built successfully are stored---by default, @file{/gnu/store}. | |
1ddee424 LC |
3628 | Sub-directories in the store are referred to as @dfn{store items} or |
3629 | sometimes @dfn{store paths}. The store has an associated database that | |
3630 | contains information such as the store paths referred to by each store | |
3631 | path, and the list of @emph{valid} store items---results of successful | |
ef5f5c86 LC |
3632 | builds. This database resides in @file{@var{localstatedir}/guix/db}, |
3633 | where @var{localstatedir} is the state directory specified @i{via} | |
3634 | @option{--localstatedir} at configure time, usually @file{/var}. | |
1ddee424 LC |
3635 | |
3636 | The store is @emph{always} accessed by the daemon on behalf of its clients | |
e531ac2a | 3637 | (@pxref{Invoking guix-daemon}). To manipulate the store, clients |
f97c9175 AE |
3638 | connect to the daemon over a Unix-domain socket, send requests to it, |
3639 | and read the result---these are remote procedure calls, or RPCs. | |
e531ac2a | 3640 | |
1ddee424 LC |
3641 | @quotation Note |
3642 | Users must @emph{never} modify files under @file{/gnu/store} directly. | |
3643 | This would lead to inconsistencies and break the immutability | |
3644 | assumptions of Guix's functional model (@pxref{Introduction}). | |
3645 | ||
3646 | @xref{Invoking guix gc, @command{guix gc --verify}}, for information on | |
3647 | how to check the integrity of the store and attempt recovery from | |
3648 | accidental modifications. | |
3649 | @end quotation | |
3650 | ||
e531ac2a LC |
3651 | The @code{(guix store)} module provides procedures to connect to the |
3652 | daemon, and to perform RPCs. These are described below. | |
3653 | ||
3654 | @deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t] | |
3655 | Connect to the daemon over the Unix-domain socket at @var{file}. When | |
3656 | @var{reserve-space?} is true, instruct it to reserve a little bit of | |
3657 | extra space on the file system so that the garbage collector can still | |
f97c9175 | 3658 | operate should the disk become full. Return a server object. |
e531ac2a LC |
3659 | |
3660 | @var{file} defaults to @var{%default-socket-path}, which is the normal | |
3661 | location given the options that were passed to @command{configure}. | |
3662 | @end deffn | |
3663 | ||
3664 | @deffn {Scheme Procedure} close-connection @var{server} | |
3665 | Close the connection to @var{server}. | |
3666 | @end deffn | |
3667 | ||
3668 | @defvr {Scheme Variable} current-build-output-port | |
3669 | This variable is bound to a SRFI-39 parameter, which refers to the port | |
3670 | where build and error logs sent by the daemon should be written. | |
3671 | @end defvr | |
3672 | ||
3673 | Procedures that make RPCs all take a server object as their first | |
3674 | argument. | |
3675 | ||
3676 | @deffn {Scheme Procedure} valid-path? @var{server} @var{path} | |
06b76acc LC |
3677 | @cindex invalid store items |
3678 | Return @code{#t} when @var{path} designates a valid store item and | |
3679 | @code{#f} otherwise (an invalid item may exist on disk but still be | |
3680 | invalid, for instance because it is the result of an aborted or failed | |
3681 | build.) | |
3682 | ||
3683 | A @code{&nix-protocol-error} condition is raised if @var{path} is not | |
3684 | prefixed by the store directory (@file{/gnu/store}). | |
e531ac2a LC |
3685 | @end deffn |
3686 | ||
cfbf9160 | 3687 | @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}] |
e531ac2a LC |
3688 | Add @var{text} under file @var{name} in the store, and return its store |
3689 | path. @var{references} is the list of store paths referred to by the | |
3690 | resulting store path. | |
3691 | @end deffn | |
3692 | ||
874e6874 | 3693 | @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations} |
59688fc4 LC |
3694 | Build @var{derivations} (a list of @code{<derivation>} objects or |
3695 | derivation paths), and return when the worker is done building them. | |
3696 | Return @code{#t} on success. | |
874e6874 LC |
3697 | @end deffn |
3698 | ||
b860f382 LC |
3699 | Note that the @code{(guix monads)} module provides a monad as well as |
3700 | monadic versions of the above procedures, with the goal of making it | |
3701 | more convenient to work with code that accesses the store (@pxref{The | |
3702 | Store Monad}). | |
3703 | ||
e531ac2a LC |
3704 | @c FIXME |
3705 | @i{This section is currently incomplete.} | |
568717fd LC |
3706 | |
3707 | @node Derivations | |
3708 | @section Derivations | |
3709 | ||
874e6874 LC |
3710 | @cindex derivations |
3711 | Low-level build actions and the environment in which they are performed | |
70458ed5 | 3712 | are represented by @dfn{derivations}. A derivation contains the |
874e6874 LC |
3713 | following pieces of information: |
3714 | ||
3715 | @itemize | |
3716 | @item | |
3717 | The outputs of the derivation---derivations produce at least one file or | |
3718 | directory in the store, but may produce more. | |
3719 | ||
3720 | @item | |
3721 | The inputs of the derivations, which may be other derivations or plain | |
3722 | files in the store (patches, build scripts, etc.) | |
3723 | ||
3724 | @item | |
3725 | The system type targeted by the derivation---e.g., @code{x86_64-linux}. | |
3726 | ||
3727 | @item | |
3728 | The file name of a build script in the store, along with the arguments | |
3729 | to be passed. | |
3730 | ||
3731 | @item | |
3732 | A list of environment variables to be defined. | |
3733 | ||
3734 | @end itemize | |
3735 | ||
3736 | @cindex derivation path | |
3737 | Derivations allow clients of the daemon to communicate build actions to | |
3738 | the store. They exist in two forms: as an in-memory representation, | |
3739 | both on the client- and daemon-side, and as files in the store whose | |
3740 | name end in @code{.drv}---these files are referred to as @dfn{derivation | |
3741 | paths}. Derivations paths can be passed to the @code{build-derivations} | |
3742 | procedure to perform the build actions they prescribe (@pxref{The | |
3743 | Store}). | |
3744 | ||
3745 | The @code{(guix derivations)} module provides a representation of | |
3746 | derivations as Scheme objects, along with procedures to create and | |
3747 | otherwise manipulate derivations. The lowest-level primitive to create | |
3748 | a derivation is the @code{derivation} procedure: | |
3749 | ||
1909431c LC |
3750 | @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @ |
3751 | @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
2096ef47 | 3752 | [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @ |
1909431c | 3753 | [#:system (%current-system)] [#:references-graphs #f] @ |
35b5ca78 LC |
3754 | [#:allowed-references #f] [#:disallowed-references #f] @ |
3755 | [#:leaked-env-vars #f] [#:local-build? #f] @ | |
4a6aeb67 | 3756 | [#:substitutable? #t] |
59688fc4 LC |
3757 | Build a derivation with the given arguments, and return the resulting |
3758 | @code{<derivation>} object. | |
874e6874 | 3759 | |
2096ef47 | 3760 | When @var{hash} and @var{hash-algo} are given, a |
874e6874 | 3761 | @dfn{fixed-output derivation} is created---i.e., one whose result is |
36bbbbd1 LC |
3762 | known in advance, such as a file download. If, in addition, |
3763 | @var{recursive?} is true, then that fixed output may be an executable | |
3764 | file or a directory and @var{hash} must be the hash of an archive | |
3765 | containing this output. | |
5b0c9d16 | 3766 | |
858e9282 | 3767 | When @var{references-graphs} is true, it must be a list of file |
5b0c9d16 LC |
3768 | name/store path pairs. In that case, the reference graph of each store |
3769 | path is exported in the build environment in the corresponding file, in | |
3770 | a simple text format. | |
1909431c | 3771 | |
b53be755 | 3772 | When @var{allowed-references} is true, it must be a list of store items |
35b5ca78 LC |
3773 | or outputs that the derivation's output may refer to. Likewise, |
3774 | @var{disallowed-references}, if true, must be a list of things the | |
3775 | outputs may @emph{not} refer to. | |
b53be755 | 3776 | |
c0468155 LC |
3777 | When @var{leaked-env-vars} is true, it must be a list of strings |
3778 | denoting environment variables that are allowed to ``leak'' from the | |
3779 | daemon's environment to the build environment. This is only applicable | |
3780 | to fixed-output derivations---i.e., when @var{hash} is true. The main | |
3781 | use is to allow variables such as @code{http_proxy} to be passed to | |
3782 | derivations that download files. | |
3783 | ||
1909431c LC |
3784 | When @var{local-build?} is true, declare that the derivation is not a |
3785 | good candidate for offloading and should rather be built locally | |
3786 | (@pxref{Daemon Offload Setup}). This is the case for small derivations | |
3787 | where the costs of data transfers would outweigh the benefits. | |
4a6aeb67 LC |
3788 | |
3789 | When @var{substitutable?} is false, declare that substitutes of the | |
3790 | derivation's output should not be used (@pxref{Substitutes}). This is | |
3791 | useful, for instance, when building packages that capture details of the | |
3792 | host CPU instruction set. | |
874e6874 LC |
3793 | @end deffn |
3794 | ||
3795 | @noindent | |
3796 | Here's an example with a shell script as its builder, assuming | |
3797 | @var{store} is an open connection to the daemon, and @var{bash} points | |
3798 | to a Bash executable in the store: | |
3799 | ||
3800 | @lisp | |
3801 | (use-modules (guix utils) | |
3802 | (guix store) | |
3803 | (guix derivations)) | |
3804 | ||
59688fc4 LC |
3805 | (let ((builder ; add the Bash script to the store |
3806 | (add-text-to-store store "my-builder.sh" | |
3807 | "echo hello world > $out\n" '()))) | |
3808 | (derivation store "foo" | |
3809 | bash `("-e" ,builder) | |
21b679f6 | 3810 | #:inputs `((,bash) (,builder)) |
59688fc4 | 3811 | #:env-vars '(("HOME" . "/homeless")))) |
834129e0 | 3812 | @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo> |
874e6874 LC |
3813 | @end lisp |
3814 | ||
21b679f6 LC |
3815 | As can be guessed, this primitive is cumbersome to use directly. A |
3816 | better approach is to write build scripts in Scheme, of course! The | |
3817 | best course of action for that is to write the build code as a | |
3818 | ``G-expression'', and to pass it to @code{gexp->derivation}. For more | |
6621cdb6 | 3819 | information, @pxref{G-Expressions}. |
21b679f6 | 3820 | |
f2fadbc1 AE |
3821 | Once upon a time, @code{gexp->derivation} did not exist and constructing |
3822 | derivations with build code written in Scheme was achieved with | |
3823 | @code{build-expression->derivation}, documented below. This procedure | |
3824 | is now deprecated in favor of the much nicer @code{gexp->derivation}. | |
3825 | ||
3826 | @deffn {Scheme Procedure} build-expression->derivation @var{store} @ | |
3827 | @var{name} @var{exp} @ | |
3828 | [#:system (%current-system)] [#:inputs '()] @ | |
3829 | [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
3830 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
3831 | [#:references-graphs #f] [#:allowed-references #f] @ | |
35b5ca78 | 3832 | [#:disallowed-references #f] @ |
f2fadbc1 AE |
3833 | [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f] |
3834 | Return a derivation that executes Scheme expression @var{exp} as a | |
3835 | builder for derivation @var{name}. @var{inputs} must be a list of | |
3836 | @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted, | |
3837 | @code{"out"} is assumed. @var{modules} is a list of names of Guile | |
3838 | modules from the current search path to be copied in the store, | |
3839 | compiled, and made available in the load path during the execution of | |
3840 | @var{exp}---e.g., @code{((guix build utils) (guix build | |
3841 | gnu-build-system))}. | |
3842 | ||
3843 | @var{exp} is evaluated in an environment where @code{%outputs} is bound | |
3844 | to a list of output/path pairs, and where @code{%build-inputs} is bound | |
3845 | to a list of string/output-path pairs made from @var{inputs}. | |
3846 | Optionally, @var{env-vars} is a list of string pairs specifying the name | |
3847 | and value of environment variables visible to the builder. The builder | |
3848 | terminates by passing the result of @var{exp} to @code{exit}; thus, when | |
3849 | @var{exp} returns @code{#f}, the build is considered to have failed. | |
3850 | ||
3851 | @var{exp} is built using @var{guile-for-build} (a derivation). When | |
3852 | @var{guile-for-build} is omitted or is @code{#f}, the value of the | |
3853 | @code{%guile-for-build} fluid is used instead. | |
3854 | ||
3855 | See the @code{derivation} procedure for the meaning of | |
35b5ca78 LC |
3856 | @var{references-graphs}, @var{allowed-references}, |
3857 | @var{disallowed-references}, @var{local-build?}, and | |
3858 | @var{substitutable?}. | |
f2fadbc1 AE |
3859 | @end deffn |
3860 | ||
3861 | @noindent | |
3862 | Here's an example of a single-output derivation that creates a directory | |
3863 | containing one file: | |
3864 | ||
3865 | @lisp | |
3866 | (let ((builder '(let ((out (assoc-ref %outputs "out"))) | |
3867 | (mkdir out) ; create /gnu/store/@dots{}-goo | |
3868 | (call-with-output-file (string-append out "/test") | |
3869 | (lambda (p) | |
3870 | (display '(hello guix) p)))))) | |
3871 | (build-expression->derivation store "goo" builder)) | |
3872 | ||
3873 | @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}> | |
3874 | @end lisp | |
3875 | ||
568717fd | 3876 | |
b860f382 LC |
3877 | @node The Store Monad |
3878 | @section The Store Monad | |
3879 | ||
3880 | @cindex monad | |
3881 | ||
3882 | The procedures that operate on the store described in the previous | |
3883 | sections all take an open connection to the build daemon as their first | |
3884 | argument. Although the underlying model is functional, they either have | |
3885 | side effects or depend on the current state of the store. | |
3886 | ||
3887 | The former is inconvenient: the connection to the build daemon has to be | |
3888 | carried around in all those functions, making it impossible to compose | |
3889 | functions that do not take that parameter with functions that do. The | |
3890 | latter can be problematic: since store operations have side effects | |
3891 | and/or depend on external state, they have to be properly sequenced. | |
3892 | ||
3893 | @cindex monadic values | |
3894 | @cindex monadic functions | |
3895 | This is where the @code{(guix monads)} module comes in. This module | |
3896 | provides a framework for working with @dfn{monads}, and a particularly | |
3897 | useful monad for our uses, the @dfn{store monad}. Monads are a | |
3898 | construct that allows two things: associating ``context'' with values | |
3899 | (in our case, the context is the store), and building sequences of | |
4827b36d | 3900 | computations (here computations include accesses to the store). Values |
b860f382 LC |
3901 | in a monad---values that carry this additional context---are called |
3902 | @dfn{monadic values}; procedures that return such values are called | |
3903 | @dfn{monadic procedures}. | |
3904 | ||
3905 | Consider this ``normal'' procedure: | |
3906 | ||
3907 | @example | |
45adbd62 LC |
3908 | (define (sh-symlink store) |
3909 | ;; Return a derivation that symlinks the 'bash' executable. | |
3910 | (let* ((drv (package-derivation store bash)) | |
3911 | (out (derivation->output-path drv)) | |
3912 | (sh (string-append out "/bin/bash"))) | |
3913 | (build-expression->derivation store "sh" | |
3914 | `(symlink ,sh %output)))) | |
b860f382 LC |
3915 | @end example |
3916 | ||
c6f30b81 LC |
3917 | Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten |
3918 | as a monadic function: | |
b860f382 LC |
3919 | |
3920 | @example | |
45adbd62 | 3921 | (define (sh-symlink) |
b860f382 | 3922 | ;; Same, but return a monadic value. |
c6f30b81 LC |
3923 | (mlet %store-monad ((drv (package->derivation bash))) |
3924 | (gexp->derivation "sh" | |
3925 | #~(symlink (string-append #$drv "/bin/bash") | |
3926 | #$output)))) | |
b860f382 LC |
3927 | @end example |
3928 | ||
4827b36d | 3929 | There are several things to note in the second version: the @code{store} |
c6f30b81 LC |
3930 | parameter is now implicit and is ``threaded'' in the calls to the |
3931 | @code{package->derivation} and @code{gexp->derivation} monadic | |
3932 | procedures, and the monadic value returned by @code{package->derivation} | |
3933 | is @dfn{bound} using @code{mlet} instead of plain @code{let}. | |
3934 | ||
3935 | As it turns out, the call to @code{package->derivation} can even be | |
3936 | omitted since it will take place implicitly, as we will see later | |
3937 | (@pxref{G-Expressions}): | |
3938 | ||
3939 | @example | |
3940 | (define (sh-symlink) | |
3941 | (gexp->derivation "sh" | |
3942 | #~(symlink (string-append #$bash "/bin/bash") | |
3943 | #$output))) | |
3944 | @end example | |
b860f382 | 3945 | |
7ce21611 | 3946 | @c See |
a01ad638 | 3947 | @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/> |
7ce21611 LC |
3948 | @c for the funny quote. |
3949 | Calling the monadic @code{sh-symlink} has no effect. As someone once | |
3950 | said, ``you exit a monad like you exit a building on fire: by running''. | |
3951 | So, to exit the monad and get the desired effect, one must use | |
3952 | @code{run-with-store}: | |
b860f382 LC |
3953 | |
3954 | @example | |
8e9aa37f CAW |
3955 | (run-with-store (open-connection) (sh-symlink)) |
3956 | @result{} /gnu/store/...-sh-symlink | |
b860f382 LC |
3957 | @end example |
3958 | ||
f97c9175 | 3959 | Note that the @code{(guix monad-repl)} module extends the Guile REPL with |
b9b86078 | 3960 | new ``meta-commands'' to make it easier to deal with monadic procedures: |
f97c9175 | 3961 | @code{run-in-store}, and @code{enter-store-monad}. The former is used |
b9b86078 LC |
3962 | to ``run'' a single monadic value through the store: |
3963 | ||
3964 | @example | |
3965 | scheme@@(guile-user)> ,run-in-store (package->derivation hello) | |
3966 | $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}> | |
3967 | @end example | |
3968 | ||
3969 | The latter enters a recursive REPL, where all the return values are | |
3970 | automatically run through the store: | |
3971 | ||
3972 | @example | |
3973 | scheme@@(guile-user)> ,enter-store-monad | |
3974 | store-monad@@(guile-user) [1]> (package->derivation hello) | |
3975 | $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}> | |
3976 | store-monad@@(guile-user) [1]> (text-file "foo" "Hello!") | |
3977 | $3 = "/gnu/store/@dots{}-foo" | |
3978 | store-monad@@(guile-user) [1]> ,q | |
3979 | scheme@@(guile-user)> | |
3980 | @end example | |
3981 | ||
3982 | @noindent | |
3983 | Note that non-monadic values cannot be returned in the | |
3984 | @code{store-monad} REPL. | |
3985 | ||
e87f0591 LC |
3986 | The main syntactic forms to deal with monads in general are provided by |
3987 | the @code{(guix monads)} module and are described below. | |
b860f382 LC |
3988 | |
3989 | @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ... | |
3990 | Evaluate any @code{>>=} or @code{return} forms in @var{body} as being | |
3991 | in @var{monad}. | |
3992 | @end deffn | |
3993 | ||
3994 | @deffn {Scheme Syntax} return @var{val} | |
3995 | Return a monadic value that encapsulates @var{val}. | |
3996 | @end deffn | |
3997 | ||
751630c9 | 3998 | @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ... |
b860f382 | 3999 | @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic |
751630c9 LC |
4000 | procedures @var{mproc}@dots{}@footnote{This operation is commonly |
4001 | referred to as ``bind'', but that name denotes an unrelated procedure in | |
4002 | Guile. Thus we use this somewhat cryptic symbol inherited from the | |
4003 | Haskell language.}. There can be one @var{mproc} or several of them, as | |
4004 | in this example: | |
4005 | ||
4006 | @example | |
4007 | (run-with-state | |
4008 | (with-monad %state-monad | |
4009 | (>>= (return 1) | |
4010 | (lambda (x) (return (+ 1 x))) | |
4011 | (lambda (x) (return (* 2 x))))) | |
4012 | 'some-state) | |
4013 | ||
4014 | @result{} 4 | |
4015 | @result{} some-state | |
4016 | @end example | |
b860f382 LC |
4017 | @end deffn |
4018 | ||
4019 | @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @ | |
4020 | @var{body} ... | |
4021 | @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @ | |
4022 | @var{body} ... | |
4023 | Bind the variables @var{var} to the monadic values @var{mval} in | |
4024 | @var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the | |
4025 | ``normal'' value @var{val}, as per @code{let}. | |
4026 | ||
4027 | @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let} | |
4028 | (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}). | |
4029 | @end deffn | |
4030 | ||
405a9d4e LC |
4031 | @deffn {Scheme System} mbegin @var{monad} @var{mexp} ... |
4032 | Bind @var{mexp} and the following monadic expressions in sequence, | |
4033 | returning the result of the last expression. | |
4034 | ||
4035 | This is akin to @code{mlet}, except that the return values of the | |
4036 | monadic expressions are ignored. In that sense, it is analogous to | |
4037 | @code{begin}, but applied to monadic expressions. | |
4038 | @end deffn | |
4039 | ||
561fb6c3 LC |
4040 | @cindex state monad |
4041 | The @code{(guix monads)} module provides the @dfn{state monad}, which | |
4042 | allows an additional value---the state---to be @emph{threaded} through | |
4043 | monadic procedure calls. | |
4044 | ||
4045 | @defvr {Scheme Variable} %state-monad | |
4046 | The state monad. Procedures in the state monad can access and change | |
4047 | the state that is threaded. | |
4048 | ||
4049 | Consider the example below. The @code{square} procedure returns a value | |
4050 | in the state monad. It returns the square of its argument, but also | |
4051 | increments the current state value: | |
4052 | ||
4053 | @example | |
4054 | (define (square x) | |
4055 | (mlet %state-monad ((count (current-state))) | |
4056 | (mbegin %state-monad | |
4057 | (set-current-state (+ 1 count)) | |
4058 | (return (* x x))))) | |
4059 | ||
4060 | (run-with-state (sequence %state-monad (map square (iota 3))) 0) | |
4061 | @result{} (0 1 4) | |
4062 | @result{} 3 | |
4063 | @end example | |
4064 | ||
4065 | When ``run'' through @var{%state-monad}, we obtain that additional state | |
4066 | value, which is the number of @code{square} calls. | |
4067 | @end defvr | |
4068 | ||
4069 | @deffn {Monadic Procedure} current-state | |
4070 | Return the current state as a monadic value. | |
4071 | @end deffn | |
4072 | ||
4073 | @deffn {Monadic Procedure} set-current-state @var{value} | |
4074 | Set the current state to @var{value} and return the previous state as a | |
4075 | monadic value. | |
4076 | @end deffn | |
4077 | ||
4078 | @deffn {Monadic Procedure} state-push @var{value} | |
4079 | Push @var{value} to the current state, which is assumed to be a list, | |
4080 | and return the previous state as a monadic value. | |
4081 | @end deffn | |
4082 | ||
4083 | @deffn {Monadic Procedure} state-pop | |
4084 | Pop a value from the current state and return it as a monadic value. | |
4085 | The state is assumed to be a list. | |
4086 | @end deffn | |
4087 | ||
4088 | @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}] | |
4089 | Run monadic value @var{mval} starting with @var{state} as the initial | |
4090 | state. Return two values: the resulting value, and the resulting state. | |
4091 | @end deffn | |
4092 | ||
e87f0591 LC |
4093 | The main interface to the store monad, provided by the @code{(guix |
4094 | store)} module, is as follows. | |
b860f382 LC |
4095 | |
4096 | @defvr {Scheme Variable} %store-monad | |
561fb6c3 LC |
4097 | The store monad---an alias for @var{%state-monad}. |
4098 | ||
4099 | Values in the store monad encapsulate accesses to the store. When its | |
4100 | effect is needed, a value of the store monad must be ``evaluated'' by | |
4101 | passing it to the @code{run-with-store} procedure (see below.) | |
b860f382 LC |
4102 | @end defvr |
4103 | ||
4104 | @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)] | |
4105 | Run @var{mval}, a monadic value in the store monad, in @var{store}, an | |
4106 | open store connection. | |
4107 | @end deffn | |
4108 | ||
ad372953 | 4109 | @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}] |
b860f382 | 4110 | Return as a monadic value the absolute file name in the store of the file |
ad372953 LC |
4111 | containing @var{text}, a string. @var{references} is a list of store items that the |
4112 | resulting text file refers to; it defaults to the empty list. | |
45adbd62 LC |
4113 | @end deffn |
4114 | ||
0a90af15 | 4115 | @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @ |
1ec32f4a | 4116 | [#:recursive? #t] [#:select? (const #t)] |
0a90af15 LC |
4117 | Return the name of @var{file} once interned in the store. Use |
4118 | @var{name} as its store name, or the basename of @var{file} if | |
4119 | @var{name} is omitted. | |
4120 | ||
4121 | When @var{recursive?} is true, the contents of @var{file} are added | |
4122 | recursively; if @var{file} designates a flat file and @var{recursive?} | |
4123 | is true, its contents are added, and its permission bits are kept. | |
4124 | ||
1ec32f4a LC |
4125 | When @var{recursive?} is true, call @code{(@var{select?} @var{file} |
4126 | @var{stat})} for each directory entry, where @var{file} is the entry's | |
4127 | absolute file name and @var{stat} is the result of @code{lstat}; exclude | |
4128 | entries for which @var{select?} does not return true. | |
4129 | ||
0a90af15 LC |
4130 | The example below adds a file to the store, under two different names: |
4131 | ||
4132 | @example | |
4133 | (run-with-store (open-connection) | |
4134 | (mlet %store-monad ((a (interned-file "README")) | |
4135 | (b (interned-file "README" "LEGU-MIN"))) | |
4136 | (return (list a b)))) | |
4137 | ||
4138 | @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN") | |
4139 | @end example | |
4140 | ||
4141 | @end deffn | |
4142 | ||
e87f0591 LC |
4143 | The @code{(guix packages)} module exports the following package-related |
4144 | monadic procedures: | |
4145 | ||
b860f382 | 4146 | @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @ |
4231f05b | 4147 | [#:system (%current-system)] [#:target #f] @ |
f97c9175 AE |
4148 | [#:output "out"] |
4149 | Return as a monadic | |
b860f382 LC |
4150 | value in the absolute file name of @var{file} within the @var{output} |
4151 | directory of @var{package}. When @var{file} is omitted, return the name | |
4231f05b LC |
4152 | of the @var{output} directory of @var{package}. When @var{target} is |
4153 | true, use it as a cross-compilation target triplet. | |
b860f382 LC |
4154 | @end deffn |
4155 | ||
b860f382 | 4156 | @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}] |
4231f05b LC |
4157 | @deffnx {Monadic Procedure} package->cross-derivation @var{package} @ |
4158 | @var{target} [@var{system}] | |
4159 | Monadic version of @code{package-derivation} and | |
4160 | @code{package-cross-derivation} (@pxref{Defining Packages}). | |
b860f382 LC |
4161 | @end deffn |
4162 | ||
4163 | ||
21b679f6 LC |
4164 | @node G-Expressions |
4165 | @section G-Expressions | |
4166 | ||
4167 | @cindex G-expression | |
4168 | @cindex build code quoting | |
4169 | So we have ``derivations'', which represent a sequence of build actions | |
4170 | to be performed to produce an item in the store (@pxref{Derivations}). | |
f97c9175 | 4171 | These build actions are performed when asking the daemon to actually |
21b679f6 LC |
4172 | build the derivations; they are run by the daemon in a container |
4173 | (@pxref{Invoking guix-daemon}). | |
4174 | ||
4175 | @cindex strata of code | |
f97c9175 | 4176 | It should come as no surprise that we like to write these build actions |
21b679f6 LC |
4177 | in Scheme. When we do that, we end up with two @dfn{strata} of Scheme |
4178 | code@footnote{The term @dfn{stratum} in this context was coined by | |
ef4ab0a4 LC |
4179 | Manuel Serrano et al.@: in the context of their work on Hop. Oleg |
4180 | Kiselyov, who has written insightful | |
4181 | @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code | |
4182 | on this topic}, refers to this kind of code generation as | |
4183 | @dfn{staging}.}: the ``host code''---code that defines packages, talks | |
4184 | to the daemon, etc.---and the ``build code''---code that actually | |
4185 | performs build actions, such as making directories, invoking | |
4186 | @command{make}, etc. | |
21b679f6 LC |
4187 | |
4188 | To describe a derivation and its build actions, one typically needs to | |
4189 | embed build code inside host code. It boils down to manipulating build | |
f97c9175 | 4190 | code as data, and the homoiconicity of Scheme---code has a direct |
21b679f6 | 4191 | representation as data---comes in handy for that. But we need more than |
f97c9175 | 4192 | the normal @code{quasiquote} mechanism in Scheme to construct build |
21b679f6 LC |
4193 | expressions. |
4194 | ||
4195 | The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of | |
4196 | S-expressions adapted to build expressions. G-expressions, or | |
f97c9175 | 4197 | @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp}, |
21b679f6 | 4198 | @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~}, |
f97c9175 AE |
4199 | @code{#$}, and @code{#$@@}), which are comparable to |
4200 | @code{quasiquote}, @code{unquote}, and @code{unquote-splicing}, | |
4827b36d | 4201 | respectively (@pxref{Expression Syntax, @code{quasiquote},, guile, |
f97c9175 | 4202 | GNU Guile Reference Manual}). However, there are major differences: |
21b679f6 LC |
4203 | |
4204 | @itemize | |
4205 | @item | |
4206 | Gexps are meant to be written to a file and run or manipulated by other | |
4207 | processes. | |
4208 | ||
4209 | @item | |
b39fc6f7 LC |
4210 | When a high-level object such as a package or derivation is unquoted |
4211 | inside a gexp, the result is as if its output file name had been | |
4212 | introduced. | |
ff40e9b7 | 4213 | |
21b679f6 LC |
4214 | @item |
4215 | Gexps carry information about the packages or derivations they refer to, | |
4216 | and these dependencies are automatically added as inputs to the build | |
4217 | processes that use them. | |
4218 | @end itemize | |
4219 | ||
c2b84676 | 4220 | @cindex lowering, of high-level objects in gexps |
343eacbe LC |
4221 | This mechanism is not limited to package and derivation |
4222 | objects: @dfn{compilers} able to ``lower'' other high-level objects to | |
c2b84676 LC |
4223 | derivations or files in the store can be defined, |
4224 | such that these objects can also be inserted | |
f97c9175 | 4225 | into gexps. For example, a useful type of high-level objects that can be |
343eacbe | 4226 | inserted in a gexp is ``file-like objects'', which make it easy to |
f97c9175 | 4227 | add files to the store and to refer to them in |
558e8b11 LC |
4228 | derivations and such (see @code{local-file} and @code{plain-file} |
4229 | below.) | |
b39fc6f7 | 4230 | |
21b679f6 LC |
4231 | To illustrate the idea, here is an example of a gexp: |
4232 | ||
4233 | @example | |
4234 | (define build-exp | |
4235 | #~(begin | |
4236 | (mkdir #$output) | |
4237 | (chdir #$output) | |
aff8ce7c | 4238 | (symlink (string-append #$coreutils "/bin/ls") |
21b679f6 LC |
4239 | "list-files"))) |
4240 | @end example | |
4241 | ||
4242 | This gexp can be passed to @code{gexp->derivation}; we obtain a | |
4243 | derivation that builds a directory containing exactly one symlink to | |
4244 | @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}: | |
4245 | ||
4246 | @example | |
4247 | (gexp->derivation "the-thing" build-exp) | |
4248 | @end example | |
4249 | ||
e20fd1bf | 4250 | As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is |
21b679f6 LC |
4251 | substituted to the reference to the @var{coreutils} package in the |
4252 | actual build code, and @var{coreutils} is automatically made an input to | |
4253 | the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp | |
f97c9175 AE |
4254 | output)}) is replaced by a string containing the directory name of the |
4255 | output of the derivation. | |
667b2508 LC |
4256 | |
4257 | @cindex cross compilation | |
4258 | In a cross-compilation context, it is useful to distinguish between | |
4259 | references to the @emph{native} build of a package---that can run on the | |
4260 | host---versus references to cross builds of a package. To that end, the | |
4261 | @code{#+} plays the same role as @code{#$}, but is a reference to a | |
4262 | native package build: | |
4263 | ||
4264 | @example | |
4265 | (gexp->derivation "vi" | |
4266 | #~(begin | |
4267 | (mkdir #$output) | |
4268 | (system* (string-append #+coreutils "/bin/ln") | |
4269 | "-s" | |
4270 | (string-append #$emacs "/bin/emacs") | |
4271 | (string-append #$output "/bin/vi"))) | |
4a3b6aa5 | 4272 | #:target "mips64el-linux-gnu") |
667b2508 LC |
4273 | @end example |
4274 | ||
4275 | @noindent | |
4276 | In the example above, the native build of @var{coreutils} is used, so | |
4277 | that @command{ln} can actually run on the host; but then the | |
4278 | cross-compiled build of @var{emacs} is referenced. | |
4279 | ||
0bb9929e LC |
4280 | @cindex imported modules, for gexps |
4281 | @findex with-imported-modules | |
4282 | Another gexp feature is @dfn{imported modules}: sometimes you want to be | |
4283 | able to use certain Guile modules from the ``host environment'' in the | |
4284 | gexp, so those modules should be imported in the ``build environment''. | |
4285 | The @code{with-imported-modules} form allows you to express that: | |
4286 | ||
4287 | @example | |
4288 | (let ((build (with-imported-modules '((guix build utils)) | |
4289 | #~(begin | |
4290 | (use-modules (guix build utils)) | |
4291 | (mkdir-p (string-append #$output "/bin")))))) | |
4292 | (gexp->derivation "empty-dir" | |
4293 | #~(begin | |
4294 | #$build | |
4295 | (display "success!\n") | |
4296 | #t))) | |
4297 | @end example | |
4298 | ||
4299 | @noindent | |
4300 | In this example, the @code{(guix build utils)} module is automatically | |
4301 | pulled into the isolated build environment of our gexp, such that | |
4302 | @code{(use-modules (guix build utils))} works as expected. | |
4303 | ||
7ca87354 LC |
4304 | @cindex module closure |
4305 | @findex source-module-closure | |
4306 | Usually you want the @emph{closure} of the module to be imported---i.e., | |
4307 | the module itself and all the modules it depends on---rather than just | |
4308 | the module; failing to do that, attempts to use the module will fail | |
4309 | because of missing dependent modules. The @code{source-module-closure} | |
4310 | procedure computes the closure of a module by looking at its source file | |
4311 | headers, which comes in handy in this case: | |
4312 | ||
4313 | @example | |
4314 | (use-modules (guix modules)) ;for 'source-module-closure' | |
4315 | ||
4316 | (with-imported-modules (source-module-closure | |
4317 | '((guix build utils) | |
4318 | (gnu build vm))) | |
4319 | (gexp->derivation "something-with-vms" | |
4320 | #~(begin | |
4321 | (use-modules (guix build utils) | |
4322 | (gnu build vm)) | |
4323 | @dots{}))) | |
4324 | @end example | |
4325 | ||
667b2508 | 4326 | The syntactic form to construct gexps is summarized below. |
21b679f6 LC |
4327 | |
4328 | @deffn {Scheme Syntax} #~@var{exp} | |
4329 | @deffnx {Scheme Syntax} (gexp @var{exp}) | |
4330 | Return a G-expression containing @var{exp}. @var{exp} may contain one | |
4331 | or more of the following forms: | |
4332 | ||
4333 | @table @code | |
4334 | @item #$@var{obj} | |
4335 | @itemx (ungexp @var{obj}) | |
b39fc6f7 LC |
4336 | Introduce a reference to @var{obj}. @var{obj} may have one of the |
4337 | supported types, for example a package or a | |
21b679f6 LC |
4338 | derivation, in which case the @code{ungexp} form is replaced by its |
4339 | output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}. | |
4340 | ||
b39fc6f7 LC |
4341 | If @var{obj} is a list, it is traversed and references to supported |
4342 | objects are substituted similarly. | |
21b679f6 LC |
4343 | |
4344 | If @var{obj} is another gexp, its contents are inserted and its | |
4345 | dependencies are added to those of the containing gexp. | |
4346 | ||
4347 | If @var{obj} is another kind of object, it is inserted as is. | |
4348 | ||
b39fc6f7 LC |
4349 | @item #$@var{obj}:@var{output} |
4350 | @itemx (ungexp @var{obj} @var{output}) | |
21b679f6 | 4351 | This is like the form above, but referring explicitly to the |
b39fc6f7 LC |
4352 | @var{output} of @var{obj}---this is useful when @var{obj} produces |
4353 | multiple outputs (@pxref{Packages with Multiple Outputs}). | |
21b679f6 | 4354 | |
667b2508 LC |
4355 | @item #+@var{obj} |
4356 | @itemx #+@var{obj}:output | |
4357 | @itemx (ungexp-native @var{obj}) | |
4358 | @itemx (ungexp-native @var{obj} @var{output}) | |
4359 | Same as @code{ungexp}, but produces a reference to the @emph{native} | |
4360 | build of @var{obj} when used in a cross compilation context. | |
4361 | ||
21b679f6 LC |
4362 | @item #$output[:@var{output}] |
4363 | @itemx (ungexp output [@var{output}]) | |
4364 | Insert a reference to derivation output @var{output}, or to the main | |
4365 | output when @var{output} is omitted. | |
4366 | ||
4367 | This only makes sense for gexps passed to @code{gexp->derivation}. | |
4368 | ||
4369 | @item #$@@@var{lst} | |
4370 | @itemx (ungexp-splicing @var{lst}) | |
4371 | Like the above, but splices the contents of @var{lst} inside the | |
4372 | containing list. | |
4373 | ||
667b2508 LC |
4374 | @item #+@@@var{lst} |
4375 | @itemx (ungexp-native-splicing @var{lst}) | |
4376 | Like the above, but refers to native builds of the objects listed in | |
4377 | @var{lst}. | |
4378 | ||
21b679f6 LC |
4379 | @end table |
4380 | ||
4381 | G-expressions created by @code{gexp} or @code{#~} are run-time objects | |
4382 | of the @code{gexp?} type (see below.) | |
4383 | @end deffn | |
4384 | ||
0bb9929e LC |
4385 | @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{} |
4386 | Mark the gexps defined in @var{body}@dots{} as requiring @var{modules} | |
d938a58b LC |
4387 | in their execution environment. |
4388 | ||
4389 | Each item in @var{modules} can be the name of a module, such as | |
4390 | @code{(guix build utils)}, or it can be a module name, followed by an | |
4391 | arrow, followed by a file-like object: | |
4392 | ||
4393 | @example | |
4394 | `((guix build utils) | |
4395 | (guix gcrypt) | |
4396 | ((guix config) => ,(scheme-file "config.scm" | |
4397 | #~(define-module @dots{})))) | |
4398 | @end example | |
4399 | ||
4400 | @noindent | |
4401 | In the example above, the first two modules are taken from the search | |
4402 | path, and the last one is created from the given file-like object. | |
0bb9929e LC |
4403 | |
4404 | This form has @emph{lexical} scope: it has an effect on the gexps | |
4405 | directly defined in @var{body}@dots{}, but not on those defined, say, in | |
4406 | procedures called from @var{body}@dots{}. | |
4407 | @end deffn | |
4408 | ||
21b679f6 LC |
4409 | @deffn {Scheme Procedure} gexp? @var{obj} |
4410 | Return @code{#t} if @var{obj} is a G-expression. | |
4411 | @end deffn | |
4412 | ||
4413 | G-expressions are meant to be written to disk, either as code building | |
4414 | some derivation, or as plain files in the store. The monadic procedures | |
4415 | below allow you to do that (@pxref{The Store Monad}, for more | |
4416 | information about monads.) | |
4417 | ||
4418 | @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @ | |
ce45eb4c | 4419 | [#:system (%current-system)] [#:target #f] [#:graft? #t] @ |
21b679f6 LC |
4420 | [#:hash #f] [#:hash-algo #f] @ |
4421 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
4684f301 | 4422 | [#:module-path @var{%load-path}] @ |
c8351d9a | 4423 | [#:references-graphs #f] [#:allowed-references #f] @ |
3f4ecf32 | 4424 | [#:disallowed-references #f] @ |
c0468155 | 4425 | [#:leaked-env-vars #f] @ |
0309e1b0 | 4426 | [#:script-name (string-append @var{name} "-builder")] @ |
4a6aeb67 | 4427 | [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f] |
21b679f6 | 4428 | Return a derivation @var{name} that runs @var{exp} (a gexp) with |
0309e1b0 LC |
4429 | @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is |
4430 | stored in a file called @var{script-name}. When @var{target} is true, | |
4431 | it is used as the cross-compilation target triplet for packages referred | |
4432 | to by @var{exp}. | |
21b679f6 | 4433 | |
0bb9929e LC |
4434 | @var{modules} is deprecated in favor of @code{with-imported-modules}. |
4435 | Its meaning is to | |
4436 | make @var{modules} available in the evaluation context of @var{exp}; | |
ce45eb4c LC |
4437 | @var{modules} is a list of names of Guile modules searched in |
4438 | @var{module-path} to be copied in the store, compiled, and made available in | |
21b679f6 LC |
4439 | the load path during the execution of @var{exp}---e.g., @code{((guix |
4440 | build utils) (guix build gnu-build-system))}. | |
4441 | ||
ce45eb4c LC |
4442 | @var{graft?} determines whether packages referred to by @var{exp} should be grafted when |
4443 | applicable. | |
4444 | ||
b53833b2 LC |
4445 | When @var{references-graphs} is true, it must be a list of tuples of one of the |
4446 | following forms: | |
4447 | ||
4448 | @example | |
4449 | (@var{file-name} @var{package}) | |
4450 | (@var{file-name} @var{package} @var{output}) | |
4451 | (@var{file-name} @var{derivation}) | |
4452 | (@var{file-name} @var{derivation} @var{output}) | |
4453 | (@var{file-name} @var{store-item}) | |
4454 | @end example | |
4455 | ||
4456 | The right-hand-side of each element of @var{references-graphs} is automatically made | |
4457 | an input of the build process of @var{exp}. In the build environment, each | |
4458 | @var{file-name} contains the reference graph of the corresponding item, in a simple | |
4459 | text format. | |
4460 | ||
c8351d9a LC |
4461 | @var{allowed-references} must be either @code{#f} or a list of output names and packages. |
4462 | In the latter case, the list denotes store items that the result is allowed to | |
4463 | refer to. Any reference to another store item will lead to a build error. | |
3f4ecf32 LC |
4464 | Similarly for @var{disallowed-references}, which can list items that must not be |
4465 | referenced by the outputs. | |
c8351d9a | 4466 | |
e20fd1bf | 4467 | The other arguments are as for @code{derivation} (@pxref{Derivations}). |
21b679f6 LC |
4468 | @end deffn |
4469 | ||
343eacbe | 4470 | @cindex file-like objects |
e1c153e0 LC |
4471 | The @code{local-file}, @code{plain-file}, @code{computed-file}, |
4472 | @code{program-file}, and @code{scheme-file} procedures below return | |
4473 | @dfn{file-like objects}. That is, when unquoted in a G-expression, | |
4474 | these objects lead to a file in the store. Consider this G-expression: | |
343eacbe LC |
4475 | |
4476 | @example | |
a9e5e92f | 4477 | #~(system* #$(file-append glibc "/sbin/nscd") "-f" |
343eacbe LC |
4478 | #$(local-file "/tmp/my-nscd.conf")) |
4479 | @end example | |
4480 | ||
4481 | The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it | |
4482 | to the store. Once expanded, for instance @i{via} | |
4483 | @code{gexp->derivation}, the G-expression refers to that copy under | |
4484 | @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp} | |
4485 | does not have any effect on what the G-expression does. | |
4486 | @code{plain-file} can be used similarly; it differs in that the file | |
4487 | content is directly passed as a string. | |
4488 | ||
d9ae938f | 4489 | @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @ |
0687fc9c | 4490 | [#:recursive? #f] [#:select? (const #t)] |
d9ae938f | 4491 | Return an object representing local file @var{file} to add to the store; this |
9d3994f7 LC |
4492 | object can be used in a gexp. If @var{file} is a relative file name, it is looked |
4493 | up relative to the source file where this form appears. @var{file} will be added to | |
4494 | the store under @var{name}--by default the base name of @var{file}. | |
d9ae938f LC |
4495 | |
4496 | When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file} | |
4497 | designates a flat file and @var{recursive?} is true, its contents are added, and its | |
4498 | permission bits are kept. | |
4499 | ||
0687fc9c LC |
4500 | When @var{recursive?} is true, call @code{(@var{select?} @var{file} |
4501 | @var{stat})} for each directory entry, where @var{file} is the entry's | |
4502 | absolute file name and @var{stat} is the result of @code{lstat}; exclude | |
4503 | entries for which @var{select?} does not return true. | |
4504 | ||
d9ae938f LC |
4505 | This is the declarative counterpart of the @code{interned-file} monadic |
4506 | procedure (@pxref{The Store Monad, @code{interned-file}}). | |
4507 | @end deffn | |
4508 | ||
558e8b11 LC |
4509 | @deffn {Scheme Procedure} plain-file @var{name} @var{content} |
4510 | Return an object representing a text file called @var{name} with the given | |
4511 | @var{content} (a string) to be added to the store. | |
4512 | ||
4513 | This is the declarative counterpart of @code{text-file}. | |
4514 | @end deffn | |
4515 | ||
91937029 | 4516 | @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @ |
a769bffb | 4517 | [#:options '(#:local-build? #t)] |
91937029 | 4518 | Return an object representing the store item @var{name}, a file or |
a769bffb | 4519 | directory computed by @var{gexp}. @var{options} |
91937029 LC |
4520 | is a list of additional arguments to pass to @code{gexp->derivation}. |
4521 | ||
4522 | This is the declarative counterpart of @code{gexp->derivation}. | |
4523 | @end deffn | |
4524 | ||
21b679f6 LC |
4525 | @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} |
4526 | Return an executable script @var{name} that runs @var{exp} using | |
9c14a487 | 4527 | @var{guile}, with @var{exp}'s imported modules in its search path. |
21b679f6 LC |
4528 | |
4529 | The example below builds a script that simply invokes the @command{ls} | |
4530 | command: | |
4531 | ||
4532 | @example | |
4533 | (use-modules (guix gexp) (gnu packages base)) | |
4534 | ||
4535 | (gexp->script "list-files" | |
a9e5e92f | 4536 | #~(execl #$(file-append coreutils "/bin/ls") |
21b679f6 LC |
4537 | "ls")) |
4538 | @end example | |
4539 | ||
4540 | When ``running'' it through the store (@pxref{The Store Monad, | |
e20fd1bf | 4541 | @code{run-with-store}}), we obtain a derivation that produces an |
21b679f6 LC |
4542 | executable file @file{/gnu/store/@dots{}-list-files} along these lines: |
4543 | ||
4544 | @example | |
4545 | #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds | |
4546 | !# | |
a9e5e92f | 4547 | (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls") |
21b679f6 LC |
4548 | @end example |
4549 | @end deffn | |
4550 | ||
15a01c72 | 4551 | @deffn {Scheme Procedure} program-file @var{name} @var{exp} @ |
9c14a487 | 4552 | [#:guile #f] |
15a01c72 LC |
4553 | Return an object representing the executable store item @var{name} that |
4554 | runs @var{gexp}. @var{guile} is the Guile package used to execute that | |
9c14a487 | 4555 | script. |
15a01c72 LC |
4556 | |
4557 | This is the declarative counterpart of @code{gexp->script}. | |
4558 | @end deffn | |
4559 | ||
2b418579 LC |
4560 | @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @ |
4561 | [#:set-load-path? #t] | |
21b679f6 | 4562 | Return a derivation that builds a file @var{name} containing @var{exp}. |
2b418579 LC |
4563 | When @var{set-load-path?} is true, emit code in the resulting file to |
4564 | set @code{%load-path} and @code{%load-compiled-path} to honor | |
4565 | @var{exp}'s imported modules. | |
21b679f6 LC |
4566 | |
4567 | The resulting file holds references to all the dependencies of @var{exp} | |
4568 | or a subset thereof. | |
4569 | @end deffn | |
1ed19464 | 4570 | |
e1c153e0 LC |
4571 | @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} |
4572 | Return an object representing the Scheme file @var{name} that contains | |
4573 | @var{exp}. | |
4574 | ||
4575 | This is the declarative counterpart of @code{gexp->file}. | |
4576 | @end deffn | |
4577 | ||
1ed19464 LC |
4578 | @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{} |
4579 | Return as a monadic value a derivation that builds a text file | |
4580 | containing all of @var{text}. @var{text} may list, in addition to | |
d9ae938f LC |
4581 | strings, objects of any type that can be used in a gexp: packages, |
4582 | derivations, local file objects, etc. The resulting store file holds | |
4583 | references to all these. | |
1ed19464 LC |
4584 | |
4585 | This variant should be preferred over @code{text-file} anytime the file | |
4586 | to create will reference items from the store. This is typically the | |
4587 | case when building a configuration file that embeds store file names, | |
4588 | like this: | |
4589 | ||
4590 | @example | |
4591 | (define (profile.sh) | |
4592 | ;; Return the name of a shell script in the store that | |
4593 | ;; initializes the 'PATH' environment variable. | |
4594 | (text-file* "profile.sh" | |
4595 | "export PATH=" coreutils "/bin:" | |
4596 | grep "/bin:" sed "/bin\n")) | |
4597 | @end example | |
4598 | ||
4599 | In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file | |
b7899749 | 4600 | will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby |
1ed19464 LC |
4601 | preventing them from being garbage-collected during its lifetime. |
4602 | @end deffn | |
21b679f6 | 4603 | |
b751cde3 LC |
4604 | @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{} |
4605 | Return an object representing store file @var{name} containing | |
4606 | @var{text}. @var{text} is a sequence of strings and file-like objects, | |
4607 | as in: | |
4608 | ||
4609 | @example | |
4610 | (mixed-text-file "profile" | |
4611 | "export PATH=" coreutils "/bin:" grep "/bin") | |
4612 | @end example | |
4613 | ||
4614 | This is the declarative counterpart of @code{text-file*}. | |
4615 | @end deffn | |
4616 | ||
a9e5e92f LC |
4617 | @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{} |
4618 | Return a file-like object that expands to the concatenation of @var{obj} | |
4619 | and @var{suffix}, where @var{obj} is a lowerable object and each | |
4620 | @var{suffix} is a string. | |
4621 | ||
4622 | As an example, consider this gexp: | |
4623 | ||
4624 | @example | |
4625 | (gexp->script "run-uname" | |
4626 | #~(system* #$(file-append coreutils | |
4627 | "/bin/uname"))) | |
4628 | @end example | |
4629 | ||
4630 | The same effect could be achieved with: | |
4631 | ||
4632 | @example | |
4633 | (gexp->script "run-uname" | |
4634 | #~(system* (string-append #$coreutils | |
4635 | "/bin/uname"))) | |
4636 | @end example | |
4637 | ||
4638 | There is one difference though: in the @code{file-append} case, the | |
4639 | resulting script contains the absolute file name as a string, whereas in | |
4640 | the second case, the resulting script contains a @code{(string-append | |
4641 | @dots{})} expression to construct the file name @emph{at run time}. | |
4642 | @end deffn | |
4643 | ||
4644 | ||
21b679f6 LC |
4645 | Of course, in addition to gexps embedded in ``host'' code, there are |
4646 | also modules containing build tools. To make it clear that they are | |
4647 | meant to be used in the build stratum, these modules are kept in the | |
4648 | @code{(guix build @dots{})} name space. | |
4649 | ||
c2b84676 LC |
4650 | @cindex lowering, of high-level objects in gexps |
4651 | Internally, high-level objects are @dfn{lowered}, using their compiler, | |
4652 | to either derivations or store items. For instance, lowering a package | |
4653 | yields a derivation, and lowering a @code{plain-file} yields a store | |
4654 | item. This is achieved using the @code{lower-object} monadic procedure. | |
4655 | ||
4656 | @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @ | |
4657 | [#:target #f] | |
4658 | Return as a value in @var{%store-monad} the derivation or store item | |
4659 | corresponding to @var{obj} for @var{system}, cross-compiling for | |
4660 | @var{target} if @var{target} is true. @var{obj} must be an object that | |
4661 | has an associated gexp compiler, such as a @code{<package>}. | |
4662 | @end deffn | |
4663 | ||
21b679f6 | 4664 | |
568717fd LC |
4665 | @c ********************************************************************* |
4666 | @node Utilities | |
4667 | @chapter Utilities | |
4668 | ||
6f773606 LC |
4669 | This section describes Guix command-line utilities. Some of them are |
4670 | primarily targeted at developers and users who write new package | |
4671 | definitions, while others are more generally useful. They complement | |
4672 | the Scheme programming interface of Guix in a convenient way. | |
210cc920 | 4673 | |
568717fd | 4674 | @menu |
37166310 | 4675 | * Invoking guix build:: Building packages from the command line. |
39bee8a2 | 4676 | * Invoking guix edit:: Editing package definitions. |
210cc920 | 4677 | * Invoking guix download:: Downloading a file and printing its hash. |
37166310 | 4678 | * Invoking guix hash:: Computing the cryptographic hash of a file. |
2f7d2d91 | 4679 | * Invoking guix import:: Importing package definitions. |
37166310 | 4680 | * Invoking guix refresh:: Updating package definitions. |
b4f5e0e8 | 4681 | * Invoking guix lint:: Finding errors in package definitions. |
fcc58db6 | 4682 | * Invoking guix size:: Profiling disk usage. |
88856916 | 4683 | * Invoking guix graph:: Visualizing the graph of packages. |
372c4bbc | 4684 | * Invoking guix environment:: Setting up development environments. |
aff8ce7c | 4685 | * Invoking guix publish:: Sharing substitutes. |
d23c20f1 | 4686 | * Invoking guix challenge:: Challenging substitute servers. |
f11c444d | 4687 | * Invoking guix copy:: Copying to and from a remote store. |
32efa254 | 4688 | * Invoking guix container:: Process isolation. |
568717fd LC |
4689 | @end menu |
4690 | ||
e49951eb MW |
4691 | @node Invoking guix build |
4692 | @section Invoking @command{guix build} | |
568717fd | 4693 | |
e32171ee JD |
4694 | @cindex package building |
4695 | @cindex @command{guix build} | |
e49951eb | 4696 | The @command{guix build} command builds packages or derivations and |
6798a8e4 LC |
4697 | their dependencies, and prints the resulting store paths. Note that it |
4698 | does not modify the user's profile---this is the job of the | |
e49951eb | 4699 | @command{guix package} command (@pxref{Invoking guix package}). Thus, |
6798a8e4 LC |
4700 | it is mainly useful for distribution developers. |
4701 | ||
4702 | The general syntax is: | |
c78bd12b LC |
4703 | |
4704 | @example | |
e49951eb | 4705 | guix build @var{options} @var{package-or-derivation}@dots{} |
c78bd12b LC |
4706 | @end example |
4707 | ||
f97c9175 | 4708 | As an example, the following command builds the latest versions of Emacs |
ccd7158d LC |
4709 | and of Guile, displays their build logs, and finally displays the |
4710 | resulting directories: | |
4711 | ||
4712 | @example | |
4713 | guix build emacs guile | |
4714 | @end example | |
4715 | ||
4716 | Similarly, the following command builds all the available packages: | |
4717 | ||
4718 | @example | |
5284339d | 4719 | guix build --quiet --keep-going \ |
ccd7158d LC |
4720 | `guix package -A | cut -f1,2 --output-delimiter=@@` |
4721 | @end example | |
4722 | ||
c78bd12b | 4723 | @var{package-or-derivation} may be either the name of a package found in |
5401dd75 | 4724 | the software distribution such as @code{coreutils} or |
e1a65ae5 | 4725 | @code{coreutils@@8.20}, or a derivation such as |
834129e0 | 4726 | @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a |
e7f34eb0 LC |
4727 | package with the corresponding name (and optionally version) is searched |
4728 | for among the GNU distribution modules (@pxref{Package Modules}). | |
4729 | ||
4730 | Alternatively, the @code{--expression} option may be used to specify a | |
4731 | Scheme expression that evaluates to a package; this is useful when | |
b7899749 | 4732 | disambiguating among several same-named packages or package variants is |
e7f34eb0 | 4733 | needed. |
c78bd12b | 4734 | |
ccd7158d LC |
4735 | There may be zero or more @var{options}. The available options are |
4736 | described in the subsections below. | |
4737 | ||
4738 | @menu | |
4739 | * Common Build Options:: Build options for most commands. | |
f11c444d | 4740 | * Package Transformation Options:: Creating variants of packages. |
ccd7158d LC |
4741 | * Additional Build Options:: Options specific to 'guix build'. |
4742 | @end menu | |
4743 | ||
4744 | @node Common Build Options | |
4745 | @subsection Common Build Options | |
4746 | ||
4747 | A number of options that control the build process are common to | |
4748 | @command{guix build} and other commands that can spawn builds, such as | |
4749 | @command{guix package} or @command{guix archive}. These are the | |
4750 | following: | |
4751 | ||
4752 | @table @code | |
4753 | ||
4754 | @item --load-path=@var{directory} | |
4755 | @itemx -L @var{directory} | |
4756 | Add @var{directory} to the front of the package module search path | |
4757 | (@pxref{Package Modules}). | |
4758 | ||
4759 | This allows users to define their own packages and make them visible to | |
4760 | the command-line tools. | |
4761 | ||
4762 | @item --keep-failed | |
4763 | @itemx -K | |
b7899749 | 4764 | Keep the build tree of failed builds. Thus, if a build fails, its build |
ccd7158d LC |
4765 | tree is kept under @file{/tmp}, in a directory whose name is shown at |
4766 | the end of the build log. This is useful when debugging build issues. | |
4767 | ||
4768 | @item --keep-going | |
4769 | @itemx -k | |
4770 | Keep going when some of the derivations fail to build; return only once | |
4771 | all the builds have either completed or failed. | |
4772 | ||
4773 | The default behavior is to stop as soon as one of the specified | |
4774 | derivations has failed. | |
4775 | ||
4776 | @item --dry-run | |
4777 | @itemx -n | |
4778 | Do not build the derivations. | |
4779 | ||
4780 | @item --fallback | |
4781 | When substituting a pre-built binary fails, fall back to building | |
4782 | packages locally. | |
4783 | ||
4784 | @item --substitute-urls=@var{urls} | |
4785 | @anchor{client-substitute-urls} | |
4786 | Consider @var{urls} the whitespace-separated list of substitute source | |
4787 | URLs, overriding the default list of URLs of @command{guix-daemon} | |
4788 | (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}). | |
4789 | ||
4790 | This means that substitutes may be downloaded from @var{urls}, provided | |
4791 | they are signed by a key authorized by the system administrator | |
4792 | (@pxref{Substitutes}). | |
4793 | ||
71e2065a LC |
4794 | When @var{urls} is the empty string, substitutes are effectively |
4795 | disabled. | |
4796 | ||
ccd7158d LC |
4797 | @item --no-substitutes |
4798 | Do not use substitutes for build products. That is, always build things | |
4799 | locally instead of allowing downloads of pre-built binaries | |
4800 | (@pxref{Substitutes}). | |
4801 | ||
7573d30f LC |
4802 | @item --no-grafts |
4803 | Do not ``graft'' packages. In practice, this means that package updates | |
4804 | available as grafts are not applied. @xref{Security Updates}, for more | |
4805 | information on grafts. | |
4806 | ||
ccd7158d LC |
4807 | @item --rounds=@var{n} |
4808 | Build each derivation @var{n} times in a row, and raise an error if | |
4809 | consecutive build results are not bit-for-bit identical. | |
4810 | ||
4811 | This is a useful way to detect non-deterministic builds processes. | |
4812 | Non-deterministic build processes are a problem because they make it | |
4813 | practically impossible for users to @emph{verify} whether third-party | |
4814 | binaries are genuine. @xref{Invoking guix challenge}, for more. | |
4815 | ||
4816 | Note that, currently, the differing build results are not kept around, | |
4817 | so you will have to manually investigate in case of an error---e.g., by | |
e66d1f59 ML |
4818 | stashing one of the build results with @code{guix archive --export} |
4819 | (@pxref{Invoking guix archive}), then rebuilding, and finally comparing | |
4820 | the two results. | |
ccd7158d LC |
4821 | |
4822 | @item --no-build-hook | |
f97c9175 | 4823 | Do not attempt to offload builds @i{via} the ``build hook'' of the daemon |
ccd7158d LC |
4824 | (@pxref{Daemon Offload Setup}). That is, always build things locally |
4825 | instead of offloading builds to remote machines. | |
4826 | ||
4827 | @item --max-silent-time=@var{seconds} | |
4828 | When the build or substitution process remains silent for more than | |
4829 | @var{seconds}, terminate it and report a build failure. | |
4830 | ||
4831 | @item --timeout=@var{seconds} | |
4832 | Likewise, when the build or substitution process lasts for more than | |
4833 | @var{seconds}, terminate it and report a build failure. | |
4834 | ||
4835 | By default there is no timeout. This behavior can be restored with | |
4836 | @code{--timeout=0}. | |
4837 | ||
4838 | @item --verbosity=@var{level} | |
4839 | Use the given verbosity level. @var{level} must be an integer between 0 | |
4840 | and 5; higher means more verbose output. Setting a level of 4 or more | |
4841 | may be helpful when debugging setup issues with the build daemon. | |
4842 | ||
4843 | @item --cores=@var{n} | |
4844 | @itemx -c @var{n} | |
4845 | Allow the use of up to @var{n} CPU cores for the build. The special | |
4846 | value @code{0} means to use as many CPU cores as available. | |
4847 | ||
4848 | @item --max-jobs=@var{n} | |
4849 | @itemx -M @var{n} | |
4850 | Allow at most @var{n} build jobs in parallel. @xref{Invoking | |
4851 | guix-daemon, @code{--max-jobs}}, for details about this option and the | |
4852 | equivalent @command{guix-daemon} option. | |
4853 | ||
4854 | @end table | |
4855 | ||
4856 | Behind the scenes, @command{guix build} is essentially an interface to | |
4857 | the @code{package-derivation} procedure of the @code{(guix packages)} | |
4858 | module, and to the @code{build-derivations} procedure of the @code{(guix | |
4859 | derivations)} module. | |
4860 | ||
4861 | In addition to options explicitly passed on the command line, | |
4862 | @command{guix build} and other @command{guix} commands that support | |
4863 | building honor the @code{GUIX_BUILD_OPTIONS} environment variable. | |
4864 | ||
4865 | @defvr {Environment Variable} GUIX_BUILD_OPTIONS | |
4866 | Users can define this variable to a list of command line options that | |
4867 | will automatically be used by @command{guix build} and other | |
4868 | @command{guix} commands that can perform builds, as in the example | |
4869 | below: | |
4870 | ||
4871 | @example | |
4872 | $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar" | |
4873 | @end example | |
4874 | ||
4875 | These options are parsed independently, and the result is appended to | |
4876 | the parsed command-line options. | |
4877 | @end defvr | |
4878 | ||
88ad6ded LC |
4879 | |
4880 | @node Package Transformation Options | |
4881 | @subsection Package Transformation Options | |
4882 | ||
4883 | @cindex package variants | |
4884 | Another set of command-line options supported by @command{guix build} | |
b8638f03 | 4885 | and also @command{guix package} are @dfn{package transformation |
f97c9175 | 4886 | options}. These are options that make it possible to define @dfn{package |
b8638f03 LC |
4887 | variants}---for instance, packages built from different source code. |
4888 | This is a convenient way to create customized packages on the fly | |
4889 | without having to type in the definitions of package variants | |
4890 | (@pxref{Defining Packages}). | |
88ad6ded LC |
4891 | |
4892 | @table @code | |
4893 | ||
4894 | @item --with-source=@var{source} | |
4895 | Use @var{source} as the source of the corresponding package. | |
4896 | @var{source} must be a file name or a URL, as for @command{guix | |
4897 | download} (@pxref{Invoking guix download}). | |
4898 | ||
f97c9175 AE |
4899 | The ``corresponding package'' is taken to be the one specified on the |
4900 | command line the name of which matches the base of @var{source}---e.g., | |
4901 | if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding | |
88ad6ded | 4902 | package is @code{guile}. Likewise, the version string is inferred from |
f97c9175 | 4903 | @var{source}; in the previous example, it is @code{2.0.10}. |
88ad6ded LC |
4904 | |
4905 | This option allows users to try out versions of packages other than the | |
4906 | one provided by the distribution. The example below downloads | |
4907 | @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for | |
4908 | the @code{ed} package: | |
4909 | ||
4910 | @example | |
4911 | guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz | |
4912 | @end example | |
4913 | ||
4914 | As a developer, @code{--with-source} makes it easy to test release | |
4915 | candidates: | |
4916 | ||
4917 | @example | |
4918 | guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz | |
4919 | @end example | |
4920 | ||
4921 | @dots{} or to build from a checkout in a pristine environment: | |
4922 | ||
4923 | @example | |
4924 | $ git clone git://git.sv.gnu.org/guix.git | |
4925 | $ guix build guix --with-source=./guix | |
4926 | @end example | |
4927 | ||
47c0f92c LC |
4928 | @item --with-input=@var{package}=@var{replacement} |
4929 | Replace dependency on @var{package} by a dependency on | |
4930 | @var{replacement}. @var{package} must be a package name, and | |
4931 | @var{replacement} must be a package specification such as @code{guile} | |
4932 | or @code{guile@@1.8}. | |
4933 | ||
f97c9175 | 4934 | For instance, the following command builds Guix, but replaces its |
47c0f92c | 4935 | dependency on the current stable version of Guile with a dependency on |
f6396d86 | 4936 | the legacy version of Guile, @code{guile@@2.0}: |
47c0f92c LC |
4937 | |
4938 | @example | |
f6396d86 | 4939 | guix build --with-input=guile=guile@@2.0 guix |
47c0f92c LC |
4940 | @end example |
4941 | ||
4942 | This is a recursive, deep replacement. So in this example, both | |
4943 | @code{guix} and its dependency @code{guile-json} (which also depends on | |
f6396d86 | 4944 | @code{guile}) get rebuilt against @code{guile@@2.0}. |
47c0f92c | 4945 | |
2a75b0b6 LC |
4946 | This is implemented using the @code{package-input-rewriting} Scheme |
4947 | procedure (@pxref{Defining Packages, @code{package-input-rewriting}}). | |
645b9df8 LC |
4948 | |
4949 | @item --with-graft=@var{package}=@var{replacement} | |
4950 | This is similar to @code{--with-input} but with an important difference: | |
9b4ec573 | 4951 | instead of rebuilding the whole dependency chain, @var{replacement} is |
645b9df8 LC |
4952 | built and then @dfn{grafted} onto the binaries that were initially |
4953 | referring to @var{package}. @xref{Security Updates}, for more | |
4954 | information on grafts. | |
4955 | ||
4956 | For example, the command below grafts version 3.5.4 of GnuTLS onto Wget | |
4957 | and all its dependencies, replacing references to the version of GnuTLS | |
4958 | they currently refer to: | |
4959 | ||
4960 | @example | |
4961 | guix build --with-graft=gnutls=gnutls@@3.5.4 wget | |
4962 | @end example | |
4963 | ||
4964 | This has the advantage of being much faster than rebuilding everything. | |
4965 | But there is a caveat: it works if and only if @var{package} and | |
4966 | @var{replacement} are strictly compatible---for example, if they provide | |
4967 | a library, the application binary interface (ABI) of those libraries | |
4968 | must be compatible. If @var{replacement} is somehow incompatible with | |
4969 | @var{package}, then the resulting package may be unusable. Use with | |
4970 | care! | |
4971 | ||
88ad6ded LC |
4972 | @end table |
4973 | ||
ccd7158d LC |
4974 | @node Additional Build Options |
4975 | @subsection Additional Build Options | |
4976 | ||
4977 | The command-line options presented below are specific to @command{guix | |
4978 | build}. | |
c78bd12b LC |
4979 | |
4980 | @table @code | |
4981 | ||
5284339d LC |
4982 | @item --quiet |
4983 | @itemx -q | |
4984 | Build quietly, without displaying the build log. Upon completion, the | |
4985 | build log is kept in @file{/var} (or similar) and can always be | |
4986 | retrieved using the @option{--log-file} option. | |
4987 | ||
34a1783f DT |
4988 | @item --file=@var{file} |
4989 | @itemx -f @var{file} | |
4990 | ||
4991 | Build the package or derivation that the code within @var{file} | |
4992 | evaluates to. | |
4993 | ||
4994 | As an example, @var{file} might contain a package definition like this | |
4995 | (@pxref{Defining Packages}): | |
4996 | ||
4997 | @example | |
4998 | @verbatiminclude package-hello.scm | |
4999 | @end example | |
5000 | ||
c78bd12b LC |
5001 | @item --expression=@var{expr} |
5002 | @itemx -e @var{expr} | |
ac5de156 | 5003 | Build the package or derivation @var{expr} evaluates to. |
c78bd12b | 5004 | |
5401dd75 | 5005 | For example, @var{expr} may be @code{(@@ (gnu packages guile) |
c78bd12b LC |
5006 | guile-1.8)}, which unambiguously designates this specific variant of |
5007 | version 1.8 of Guile. | |
5008 | ||
f97c9175 | 5009 | Alternatively, @var{expr} may be a G-expression, in which case it is used |
56b82106 LC |
5010 | as a build program passed to @code{gexp->derivation} |
5011 | (@pxref{G-Expressions}). | |
5012 | ||
5013 | Lastly, @var{expr} may refer to a zero-argument monadic procedure | |
ac5de156 LC |
5014 | (@pxref{The Store Monad}). The procedure must return a derivation as a |
5015 | monadic value, which is then passed through @code{run-with-store}. | |
5016 | ||
c78bd12b LC |
5017 | @item --source |
5018 | @itemx -S | |
f97c9175 | 5019 | Build the source derivations of the packages, rather than the packages |
c78bd12b LC |
5020 | themselves. |
5021 | ||
e49951eb | 5022 | For instance, @code{guix build -S gcc} returns something like |
f97c9175 AE |
5023 | @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC |
5024 | source tarball. | |
c78bd12b | 5025 | |
f9cc8971 | 5026 | The returned source tarball is the result of applying any patches and |
f97c9175 | 5027 | code snippets specified in the package @code{origin} (@pxref{Defining |
f9cc8971 LC |
5028 | Packages}). |
5029 | ||
2cdfe13d EB |
5030 | @item --sources |
5031 | Fetch and return the source of @var{package-or-derivation} and all their | |
5032 | dependencies, recursively. This is a handy way to obtain a local copy | |
5033 | of all the source code needed to build @var{packages}, allowing you to | |
5034 | eventually build them even without network access. It is an extension | |
5035 | of the @code{--source} option and can accept one of the following | |
5036 | optional argument values: | |
5037 | ||
5038 | @table @code | |
5039 | @item package | |
5040 | This value causes the @code{--sources} option to behave in the same way | |
5041 | as the @code{--source} option. | |
5042 | ||
5043 | @item all | |
f97c9175 AE |
5044 | Build the source derivations of all packages, including any source that |
5045 | might be listed as @code{inputs}. This is the default value. | |
2cdfe13d EB |
5046 | |
5047 | @example | |
5048 | $ guix build --sources tzdata | |
5049 | The following derivations will be built: | |
5050 | /gnu/store/@dots{}-tzdata2015b.tar.gz.drv | |
5051 | /gnu/store/@dots{}-tzcode2015b.tar.gz.drv | |
5052 | @end example | |
5053 | ||
5054 | @item transitive | |
f97c9175 AE |
5055 | Build the source derivations of all packages, as well of all transitive |
5056 | inputs to the packages. This can be used e.g. to | |
2cdfe13d EB |
5057 | prefetch package source for later offline building. |
5058 | ||
5059 | @example | |
5060 | $ guix build --sources=transitive tzdata | |
5061 | The following derivations will be built: | |
5062 | /gnu/store/@dots{}-tzcode2015b.tar.gz.drv | |
5063 | /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv | |
5064 | /gnu/store/@dots{}-grep-2.21.tar.xz.drv | |
5065 | /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv | |
5066 | /gnu/store/@dots{}-make-4.1.tar.xz.drv | |
5067 | /gnu/store/@dots{}-bash-4.3.tar.xz.drv | |
5068 | @dots{} | |
5069 | @end example | |
5070 | ||
5071 | @end table | |
5072 | ||
c78bd12b LC |
5073 | @item --system=@var{system} |
5074 | @itemx -s @var{system} | |
5075 | Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of | |
f97c9175 | 5076 | the system type of the build host. |
c78bd12b LC |
5077 | |
5078 | An example use of this is on Linux-based systems, which can emulate | |
5079 | different personalities. For instance, passing | |
5080 | @code{--system=i686-linux} on an @code{x86_64-linux} system allows users | |
5081 | to build packages in a complete 32-bit environment. | |
5082 | ||
e55ec43d LC |
5083 | @item --target=@var{triplet} |
5084 | @cindex cross-compilation | |
5085 | Cross-build for @var{triplet}, which must be a valid GNU triplet, such | |
5461115e LC |
5086 | as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU |
5087 | configuration triplets,, autoconf, Autoconf}). | |
e55ec43d | 5088 | |
a8d65643 LC |
5089 | @anchor{build-check} |
5090 | @item --check | |
5091 | @cindex determinism, checking | |
5092 | @cindex reproducibility, checking | |
5093 | Rebuild @var{package-or-derivation}, which are already available in the | |
5094 | store, and raise an error if the build results are not bit-for-bit | |
5095 | identical. | |
5096 | ||
f97c9175 AE |
5097 | This mechanism allows you to check whether previously installed |
5098 | substitutes are genuine (@pxref{Substitutes}), or whether the build result | |
5099 | of a package is deterministic. @xref{Invoking guix challenge}, for more | |
a8d65643 LC |
5100 | background information and tools. |
5101 | ||
7f3b2510 ED |
5102 | When used in conjunction with @option{--keep-failed}, the differing |
5103 | output is kept in the store, under @file{/gnu/store/@dots{}-check}. | |
5104 | This makes it easy to look for differences between the two results. | |
5105 | ||
6da5bb7b LC |
5106 | @item --repair |
5107 | @cindex repairing store items | |
5108 | @cindex corruption, recovering from | |
5109 | Attempt to repair the specified store items, if they are corrupt, by | |
5110 | re-downloading or rebuilding them. | |
5111 | ||
5112 | This operation is not atomic and thus restricted to @code{root}. | |
5113 | ||
c78bd12b LC |
5114 | @item --derivations |
5115 | @itemx -d | |
5116 | Return the derivation paths, not the output paths, of the given | |
5117 | packages. | |
5118 | ||
70ee5642 LC |
5119 | @item --root=@var{file} |
5120 | @itemx -r @var{file} | |
5121 | Make @var{file} a symlink to the result, and register it as a garbage | |
5122 | collector root. | |
5123 | ||
5124 | @item --log-file | |
3f208ad7 | 5125 | Return the build log file names or URLs for the given |
f97c9175 | 5126 | @var{package-or-derivation}, or raise an error if build logs are |
70ee5642 LC |
5127 | missing. |
5128 | ||
5129 | This works regardless of how packages or derivations are specified. For | |
5130 | instance, the following invocations are equivalent: | |
5131 | ||
5132 | @example | |
5133 | guix build --log-file `guix build -d guile` | |
5134 | guix build --log-file `guix build guile` | |
5135 | guix build --log-file guile | |
5136 | guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)' | |
5137 | @end example | |
5138 | ||
3f208ad7 LC |
5139 | If a log is unavailable locally, and unless @code{--no-substitutes} is |
5140 | passed, the command looks for a corresponding log on one of the | |
5141 | substitute servers (as specified with @code{--substitute-urls}.) | |
70ee5642 | 5142 | |
f97c9175 AE |
5143 | So for instance, imagine you want to see the build log of GDB on MIPS, |
5144 | but you are actually on an @code{x86_64} machine: | |
3f208ad7 LC |
5145 | |
5146 | @example | |
a01ad638 | 5147 | $ guix build --log-file gdb -s mips64el-linux |
df061d07 | 5148 | https://hydra.gnu.org/log/@dots{}-gdb-7.10 |
3f208ad7 LC |
5149 | @end example |
5150 | ||
5151 | You can freely access a huge library of build logs! | |
70ee5642 LC |
5152 | @end table |
5153 | ||
16eb115e | 5154 | |
39bee8a2 LC |
5155 | @node Invoking guix edit |
5156 | @section Invoking @command{guix edit} | |
5157 | ||
e32171ee | 5158 | @cindex @command{guix edit} |
39bee8a2 LC |
5159 | @cindex package definition, editing |
5160 | So many packages, so many source files! The @command{guix edit} command | |
424a323e GC |
5161 | facilitates the life of users and packagers by pointing their editor at |
5162 | the source file containing the definition of the specified packages. | |
5163 | For instance: | |
39bee8a2 LC |
5164 | |
5165 | @example | |
7b9a66e5 | 5166 | guix edit gcc@@4.9 vim |
39bee8a2 LC |
5167 | @end example |
5168 | ||
5169 | @noindent | |
6237b9fa | 5170 | launches the program specified in the @code{VISUAL} or in the |
424a323e | 5171 | @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3 |
6237b9fa | 5172 | and that of Vim. |
39bee8a2 | 5173 | |
424a323e GC |
5174 | If you are using a Guix Git checkout (@pxref{Building from Git}), or |
5175 | have created your own packages on @code{GUIX_PACKAGE_PATH} | |
5176 | (@pxref{Defining Packages}), you will be able to edit the package | |
5177 | recipes. Otherwise, you will be able to examine the read-only recipes | |
5178 | for packages currently in the store. | |
5179 | ||
39bee8a2 | 5180 | |
210cc920 LC |
5181 | @node Invoking guix download |
5182 | @section Invoking @command{guix download} | |
5183 | ||
e32171ee JD |
5184 | @cindex @command{guix download} |
5185 | @cindex downloading package sources | |
210cc920 | 5186 | When writing a package definition, developers typically need to download |
f97c9175 | 5187 | a source tarball, compute its SHA256 hash, and write that |
210cc920 LC |
5188 | hash in the package definition (@pxref{Defining Packages}). The |
5189 | @command{guix download} tool helps with this task: it downloads a file | |
5190 | from the given URI, adds it to the store, and prints both its file name | |
5191 | in the store and its SHA256 hash. | |
5192 | ||
5193 | The fact that the downloaded file is added to the store saves bandwidth: | |
5194 | when the developer eventually tries to build the newly defined package | |
5195 | with @command{guix build}, the source tarball will not have to be | |
5196 | downloaded again because it is already in the store. It is also a | |
5197 | convenient way to temporarily stash files, which may be deleted | |
5198 | eventually (@pxref{Invoking guix gc}). | |
5199 | ||
5200 | The @command{guix download} command supports the same URIs as used in | |
5201 | package definitions. In particular, it supports @code{mirror://} URIs. | |
5202 | @code{https} URIs (HTTP over TLS) are supported @emph{provided} the | |
5203 | Guile bindings for GnuTLS are available in the user's environment; when | |
537c8bb3 LC |
5204 | they are not available, an error is raised. @xref{Guile Preparations, |
5205 | how to install the GnuTLS bindings for Guile,, gnutls-guile, | |
5206 | GnuTLS-Guile}, for more information. | |
210cc920 | 5207 | |
bc3c41ce LC |
5208 | @command{guix download} verifies HTTPS server certificates by loading |
5209 | the certificates of X.509 authorities from the directory pointed to by | |
5210 | the @code{SSL_CERT_DIR} environment variable (@pxref{X.509 | |
64b8695c | 5211 | Certificates}), unless @option{--no-check-certificate} is used. |
bc3c41ce | 5212 | |
64b8695c | 5213 | The following options are available: |
210cc920 LC |
5214 | |
5215 | @table @code | |
5216 | @item --format=@var{fmt} | |
5217 | @itemx -f @var{fmt} | |
5218 | Write the hash in the format specified by @var{fmt}. For more | |
081145cf | 5219 | information on the valid values for @var{fmt}, @pxref{Invoking guix hash}. |
64b8695c LC |
5220 | |
5221 | @item --no-check-certificate | |
5222 | Do not validate the X.509 certificates of HTTPS servers. | |
5223 | ||
5224 | When using this option, you have @emph{absolutely no guarantee} that you | |
5225 | are communicating with the authentic server responsible for the given | |
5226 | URL, which makes you vulnerable to ``man-in-the-middle'' attacks. | |
5227 | ||
1bcc87bb LC |
5228 | @item --output=@var{file} |
5229 | @itemx -o @var{file} | |
5230 | Save the downloaded file to @var{file} instead of adding it to the | |
5231 | store. | |
210cc920 LC |
5232 | @end table |
5233 | ||
6c365eca NK |
5234 | @node Invoking guix hash |
5235 | @section Invoking @command{guix hash} | |
5236 | ||
e32171ee | 5237 | @cindex @command{guix hash} |
210cc920 | 5238 | The @command{guix hash} command computes the SHA256 hash of a file. |
6c365eca NK |
5239 | It is primarily a convenience tool for anyone contributing to the |
5240 | distribution: it computes the cryptographic hash of a file, which can be | |
5241 | used in the definition of a package (@pxref{Defining Packages}). | |
5242 | ||
5243 | The general syntax is: | |
5244 | ||
5245 | @example | |
5246 | guix hash @var{option} @var{file} | |
5247 | @end example | |
5248 | ||
343dc117 LC |
5249 | When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the |
5250 | hash of data read from standard input. @command{guix hash} has the | |
5251 | following options: | |
6c365eca NK |
5252 | |
5253 | @table @code | |
5254 | ||
5255 | @item --format=@var{fmt} | |
5256 | @itemx -f @var{fmt} | |
210cc920 | 5257 | Write the hash in the format specified by @var{fmt}. |
6c365eca NK |
5258 | |
5259 | Supported formats: @code{nix-base32}, @code{base32}, @code{base16} | |
5260 | (@code{hex} and @code{hexadecimal} can be used as well). | |
5261 | ||
5262 | If the @option{--format} option is not specified, @command{guix hash} | |
5263 | will output the hash in @code{nix-base32}. This representation is used | |
5264 | in the definitions of packages. | |
5265 | ||
3140f2df LC |
5266 | @item --recursive |
5267 | @itemx -r | |
5268 | Compute the hash on @var{file} recursively. | |
5269 | ||
5270 | In this case, the hash is computed on an archive containing @var{file}, | |
f97c9175 AE |
5271 | including its children if it is a directory. Some of the metadata of |
5272 | @var{file} is part of the archive; for instance, when @var{file} is a | |
3140f2df | 5273 | regular file, the hash is different depending on whether @var{file} is |
f97c9175 | 5274 | executable or not. Metadata such as time stamps has no impact on the |
3140f2df LC |
5275 | hash (@pxref{Invoking guix archive}). |
5276 | @c FIXME: Replace xref above with xref to an ``Archive'' section when | |
5277 | @c it exists. | |
5278 | ||
392a4e12 JN |
5279 | @item --exclude-vcs |
5280 | @itemx -x | |
5281 | When combined with @option{--recursive}, exclude version control system | |
5282 | directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.) | |
5283 | ||
db97a03a LC |
5284 | @vindex git-fetch |
5285 | As an example, here is how you would compute the hash of a Git checkout, | |
5286 | which is useful when using the @code{git-fetch} method (@pxref{origin | |
5287 | Reference}): | |
5288 | ||
5289 | @example | |
5290 | $ git clone http://example.org/foo.git | |
5291 | $ cd foo | |
392a4e12 | 5292 | $ guix hash -rx . |
db97a03a | 5293 | @end example |
6c365eca NK |
5294 | @end table |
5295 | ||
2f7d2d91 LC |
5296 | @node Invoking guix import |
5297 | @section Invoking @command{guix import} | |
5298 | ||
5299 | @cindex importing packages | |
5300 | @cindex package import | |
5301 | @cindex package conversion | |
e32171ee | 5302 | @cindex Invoking @command{guix import} |
f97c9175 AE |
5303 | The @command{guix import} command is useful for people who would like to |
5304 | add a package to the distribution with as little work as | |
5305 | possible---a legitimate demand. The command knows of a few | |
5306 | repositories from which it can ``import'' package metadata. The result | |
2f7d2d91 LC |
5307 | is a package definition, or a template thereof, in the format we know |
5308 | (@pxref{Defining Packages}). | |
5309 | ||
5310 | The general syntax is: | |
5311 | ||
5312 | @example | |
5313 | guix import @var{importer} @var{options}@dots{} | |
5314 | @end example | |
5315 | ||
5316 | @var{importer} specifies the source from which to import package | |
f97c9175 | 5317 | metadata, and @var{options} specifies a package identifier and other |
2f7d2d91 LC |
5318 | options specific to @var{importer}. Currently, the available |
5319 | ``importers'' are: | |
5320 | ||
5321 | @table @code | |
5322 | @item gnu | |
f97c9175 | 5323 | Import metadata for the given GNU package. This provides a template |
2f7d2d91 LC |
5324 | for the latest version of that GNU package, including the hash of its |
5325 | source tarball, and its canonical synopsis and description. | |
5326 | ||
f97c9175 | 5327 | Additional information such as the package dependencies and its |
2f7d2d91 LC |
5328 | license needs to be figured out manually. |
5329 | ||
5330 | For example, the following command returns a package definition for | |
5331 | GNU@tie{}Hello: | |
5332 | ||
5333 | @example | |
5334 | guix import gnu hello | |
5335 | @end example | |
5336 | ||
5337 | Specific command-line options are: | |
5338 | ||
5339 | @table @code | |
5340 | @item --key-download=@var{policy} | |
5341 | As for @code{guix refresh}, specify the policy to handle missing OpenPGP | |
f97c9175 | 5342 | keys when verifying the package signature. @xref{Invoking guix |
2f7d2d91 LC |
5343 | refresh, @code{--key-download}}. |
5344 | @end table | |
5345 | ||
5346 | @item pypi | |
5347 | @cindex pypi | |
f97c9175 | 5348 | Import metadata from the @uref{https://pypi.python.org/, Python Package |
2f7d2d91 LC |
5349 | Index}@footnote{This functionality requires Guile-JSON to be installed. |
5350 | @xref{Requirements}.}. Information is taken from the JSON-formatted | |
5351 | description available at @code{pypi.python.org} and usually includes all | |
266785d2 CR |
5352 | the relevant information, including package dependencies. For maximum |
5353 | efficiency, it is recommended to install the @command{unzip} utility, so | |
5354 | that the importer can unzip Python wheels and gather data from them. | |
2f7d2d91 | 5355 | |
f97c9175 | 5356 | The command below imports metadata for the @code{itsdangerous} Python |
2f7d2d91 LC |
5357 | package: |
5358 | ||
5359 | @example | |
5360 | guix import pypi itsdangerous | |
5361 | @end example | |
5362 | ||
3aae8145 DT |
5363 | @item gem |
5364 | @cindex gem | |
f97c9175 | 5365 | Import metadata from @uref{https://rubygems.org/, |
3aae8145 DT |
5366 | RubyGems}@footnote{This functionality requires Guile-JSON to be |
5367 | installed. @xref{Requirements}.}. Information is taken from the | |
5368 | JSON-formatted description available at @code{rubygems.org} and includes | |
5369 | most relevant information, including runtime dependencies. There are | |
f97c9175 | 5370 | some caveats, however. The metadata doesn't distinguish between |
3aae8145 DT |
5371 | synopses and descriptions, so the same string is used for both fields. |
5372 | Additionally, the details of non-Ruby dependencies required to build | |
5373 | native extensions is unavailable and left as an exercise to the | |
5374 | packager. | |
5375 | ||
f97c9175 | 5376 | The command below imports metadata for the @code{rails} Ruby package: |
3aae8145 DT |
5377 | |
5378 | @example | |
5379 | guix import gem rails | |
5380 | @end example | |
5381 | ||
d45dc6da EB |
5382 | @item cpan |
5383 | @cindex CPAN | |
3c192e4e AE |
5384 | Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}@footnote{This |
5385 | functionality requires Guile-JSON to be installed. | |
5386 | @xref{Requirements}.}. | |
f97c9175 | 5387 | Information is taken from the JSON-formatted metadata provided through |
d45dc6da | 5388 | @uref{https://api.metacpan.org/, MetaCPAN's API} and includes most |
66392e47 EB |
5389 | relevant information, such as module dependencies. License information |
5390 | should be checked closely. If Perl is available in the store, then the | |
5391 | @code{corelist} utility will be used to filter core modules out of the | |
5392 | list of dependencies. | |
d45dc6da | 5393 | |
f97c9175 | 5394 | The command command below imports metadata for the @code{Acme::Boolean} |
d45dc6da EB |
5395 | Perl module: |
5396 | ||
5397 | @example | |
5398 | guix import cpan Acme::Boolean | |
5399 | @end example | |
5400 | ||
e1248602 RW |
5401 | @item cran |
5402 | @cindex CRAN | |
d0bd632f | 5403 | @cindex Bioconductor |
f97c9175 | 5404 | Import metadata from @uref{http://cran.r-project.org/, CRAN}, the |
e1248602 RW |
5405 | central repository for the @uref{http://r-project.org, GNU@tie{}R |
5406 | statistical and graphical environment}. | |
5407 | ||
f97c9175 | 5408 | Information is extracted from the @code{DESCRIPTION} file of the package. |
e1248602 | 5409 | |
f97c9175 | 5410 | The command command below imports metadata for the @code{Cairo} |
e1248602 RW |
5411 | R package: |
5412 | ||
5413 | @example | |
5414 | guix import cran Cairo | |
5415 | @end example | |
5416 | ||
64ce53eb RW |
5417 | When @code{--recursive} is added, the importer will traverse the |
5418 | dependency graph of the given upstream package recursively and generate | |
5419 | package expressions for all those packages that are not yet in Guix. | |
5420 | ||
f97c9175 | 5421 | When @code{--archive=bioconductor} is added, metadata is imported from |
d0bd632f RW |
5422 | @uref{http://www.bioconductor.org/, Bioconductor}, a repository of R |
5423 | packages for for the analysis and comprehension of high-throughput | |
5424 | genomic data in bioinformatics. | |
5425 | ||
f97c9175 | 5426 | Information is extracted from the @code{DESCRIPTION} file of a package |
d0bd632f RW |
5427 | published on the web interface of the Bioconductor SVN repository. |
5428 | ||
f97c9175 | 5429 | The command below imports metadata for the @code{GenomicRanges} |
d0bd632f RW |
5430 | R package: |
5431 | ||
5432 | @example | |
5433 | guix import cran --archive=bioconductor GenomicRanges | |
5434 | @end example | |
5435 | ||
2f7d2d91 | 5436 | @item nix |
f97c9175 | 5437 | Import metadata from a local copy of the source of the |
2f7d2d91 LC |
5438 | @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This |
5439 | relies on the @command{nix-instantiate} command of | |
5440 | @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are | |
5441 | typically written in a mixture of Nix-language and Bash code. This | |
5442 | command only imports the high-level package structure that is written in | |
5443 | the Nix language. It normally includes all the basic fields of a | |
5444 | package definition. | |
5445 | ||
5446 | When importing a GNU package, the synopsis and descriptions are replaced | |
5447 | by their canonical upstream variant. | |
5448 | ||
961d0d2d LC |
5449 | Usually, you will first need to do: |
5450 | ||
5451 | @example | |
5452 | export NIX_REMOTE=daemon | |
5453 | @end example | |
5454 | ||
5455 | @noindent | |
5456 | so that @command{nix-instantiate} does not try to open the Nix database. | |
5457 | ||
2f7d2d91 LC |
5458 | As an example, the command below imports the package definition of |
5459 | LibreOffice (more precisely, it imports the definition of the package | |
5460 | bound to the @code{libreoffice} top-level attribute): | |
5461 | ||
5462 | @example | |
5463 | guix import nix ~/path/to/nixpkgs libreoffice | |
5464 | @end example | |
863af4e1 FB |
5465 | |
5466 | @item hackage | |
5467 | @cindex hackage | |
f97c9175 | 5468 | Import metadata from the Haskell community's central package archive |
863af4e1 FB |
5469 | @uref{https://hackage.haskell.org/, Hackage}. Information is taken from |
5470 | Cabal files and includes all the relevant information, including package | |
5471 | dependencies. | |
5472 | ||
5473 | Specific command-line options are: | |
5474 | ||
5475 | @table @code | |
a4154748 FB |
5476 | @item --stdin |
5477 | @itemx -s | |
f97c9175 | 5478 | Read a Cabal file from standard input. |
863af4e1 FB |
5479 | @item --no-test-dependencies |
5480 | @itemx -t | |
f97c9175 | 5481 | Do not include dependencies required only by the test suites. |
a4154748 FB |
5482 | @item --cabal-environment=@var{alist} |
5483 | @itemx -e @var{alist} | |
5484 | @var{alist} is a Scheme alist defining the environment in which the | |
5485 | Cabal conditionals are evaluated. The accepted keys are: @code{os}, | |
5486 | @code{arch}, @code{impl} and a string representing the name of a flag. | |
5487 | The value associated with a flag has to be either the symbol | |
5488 | @code{true} or @code{false}. The value associated with other keys | |
5489 | has to conform to the Cabal file format definition. The default value | |
5490 | associated with the keys @code{os}, @code{arch} and @code{impl} is | |
f97c9175 | 5491 | @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively. |
863af4e1 FB |
5492 | @end table |
5493 | ||
f97c9175 | 5494 | The command below imports metadata for the latest version of the |
a4154748 FB |
5495 | @code{HTTP} Haskell package without including test dependencies and |
5496 | specifying the value of the flag @samp{network-uri} as @code{false}: | |
863af4e1 FB |
5497 | |
5498 | @example | |
a4154748 | 5499 | guix import hackage -t -e "'((\"network-uri\" . false))" HTTP |
863af4e1 FB |
5500 | @end example |
5501 | ||
5502 | A specific package version may optionally be specified by following the | |
1b846da8 | 5503 | package name by an at-sign and a version number as in the following example: |
863af4e1 FB |
5504 | |
5505 | @example | |
1b846da8 | 5506 | guix import hackage mtl@@2.1.3.1 |
863af4e1 | 5507 | @end example |
7f74a931 | 5508 | |
bc5844d1 FB |
5509 | @item stackage |
5510 | @cindex stackage | |
5511 | The @code{stackage} importer is a wrapper around the @code{hackage} one. | |
5512 | It takes a package name, looks up the package version included in a | |
5513 | long-term support (LTS) @uref{https://www.stackage.org, Stackage} | |
5514 | release and uses the @code{hackage} importer to retrieve its metadata. | |
5515 | Note that it is up to you to select an LTS release compatible with the | |
5516 | GHC compiler used by Guix. | |
5517 | ||
5518 | Specific command-line options are: | |
5519 | ||
5520 | @table @code | |
5521 | @item --no-test-dependencies | |
5522 | @itemx -t | |
5523 | Do not include dependencies required only by the test suites. | |
5524 | @item --lts-version=@var{version} | |
5525 | @itemx -r @var{version} | |
5526 | @var{version} is the desired LTS release version. If omitted the latest | |
5527 | release is used. | |
5528 | @end table | |
5529 | ||
5530 | The command below imports metadata for the @code{HTTP} Haskell package | |
5531 | included in the LTS Stackage release version 7.18: | |
5532 | ||
5533 | @example | |
5534 | guix import stackage --lts-version=7.18 HTTP | |
5535 | @end example | |
5536 | ||
7f74a931 FB |
5537 | @item elpa |
5538 | @cindex elpa | |
f97c9175 | 5539 | Import metadata from an Emacs Lisp Package Archive (ELPA) package |
7f74a931 FB |
5540 | repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}). |
5541 | ||
5542 | Specific command-line options are: | |
5543 | ||
5544 | @table @code | |
5545 | @item --archive=@var{repo} | |
5546 | @itemx -a @var{repo} | |
5547 | @var{repo} identifies the archive repository from which to retrieve the | |
5548 | information. Currently the supported repositories and their identifiers | |
5549 | are: | |
5550 | @itemize - | |
5551 | @item | |
840bd1d3 | 5552 | @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu} |
7f74a931 FB |
5553 | identifier. This is the default. |
5554 | ||
624144e0 LC |
5555 | Packages from @code{elpa.gnu.org} are signed with one of the keys |
5556 | contained in the GnuPG keyring at | |
5557 | @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the | |
5558 | @code{emacs} package (@pxref{Package Installation, ELPA package | |
5559 | signatures,, emacs, The GNU Emacs Manual}). | |
5560 | ||
7f74a931 | 5561 | @item |
840bd1d3 | 5562 | @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the |
7f74a931 FB |
5563 | @code{melpa-stable} identifier. |
5564 | ||
5565 | @item | |
840bd1d3 | 5566 | @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa} |
7f74a931 FB |
5567 | identifier. |
5568 | @end itemize | |
5569 | @end table | |
3e0c0365 DC |
5570 | |
5571 | @item crate | |
5572 | @cindex crate | |
5573 | Import metadata from the crates.io Rust package repository | |
5574 | @uref{https://crates.io, crates.io}. | |
2f7d2d91 LC |
5575 | @end table |
5576 | ||
5577 | The structure of the @command{guix import} code is modular. It would be | |
5578 | useful to have more importers for other package formats, and your help | |
5579 | is welcome here (@pxref{Contributing}). | |
5580 | ||
37166310 LC |
5581 | @node Invoking guix refresh |
5582 | @section Invoking @command{guix refresh} | |
5583 | ||
e32171ee | 5584 | @cindex @command {guix refresh} |
37166310 LC |
5585 | The primary audience of the @command{guix refresh} command is developers |
5586 | of the GNU software distribution. By default, it reports any packages | |
5587 | provided by the distribution that are outdated compared to the latest | |
5588 | upstream version, like this: | |
5589 | ||
5590 | @example | |
5591 | $ guix refresh | |
5592 | gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1 | |
5593 | gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0 | |
5594 | @end example | |
5595 | ||
e9c72306 LC |
5596 | Alternately, one can specify packages to consider, in which case a |
5597 | warning is emitted for packages that lack an updater: | |
5598 | ||
5599 | @example | |
5600 | $ guix refresh coreutils guile guile-ssh | |
5601 | gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh | |
5602 | gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13 | |
5603 | @end example | |
5604 | ||
5605 | @command{guix refresh} browses the upstream repository of each package and determines | |
5606 | the highest version number of the releases therein. The command | |
bcb571cb | 5607 | knows how to update specific types of packages: GNU packages, ELPA |
e9c72306 | 5608 | packages, etc.---see the documentation for @option{--type} below. There |
bcb571cb LC |
5609 | are many packages, though, for which it lacks a method to determine |
5610 | whether a new upstream release is available. However, the mechanism is | |
5611 | extensible, so feel free to get in touch with us to add a new method! | |
37166310 LC |
5612 | |
5613 | When passed @code{--update}, it modifies distribution source files to | |
f97c9175 | 5614 | update the version numbers and source tarball hashes of those package |
37166310 LC |
5615 | recipes (@pxref{Defining Packages}). This is achieved by downloading |
5616 | each package's latest source tarball and its associated OpenPGP | |
5617 | signature, authenticating the downloaded tarball against its signature | |
5618 | using @command{gpg}, and finally computing its hash. When the public | |
5619 | key used to sign the tarball is missing from the user's keyring, an | |
5620 | attempt is made to automatically retrieve it from a public key server; | |
f97c9175 | 5621 | when this is successful, the key is added to the user's keyring; otherwise, |
37166310 LC |
5622 | @command{guix refresh} reports an error. |
5623 | ||
5624 | The following options are supported: | |
5625 | ||
5626 | @table @code | |
5627 | ||
2d7fc7da LC |
5628 | @item --expression=@var{expr} |
5629 | @itemx -e @var{expr} | |
5630 | Consider the package @var{expr} evaluates to. | |
5631 | ||
5632 | This is useful to precisely refer to a package, as in this example: | |
5633 | ||
5634 | @example | |
5635 | guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)' | |
5636 | @end example | |
5637 | ||
5638 | This command lists the dependents of the ``final'' libc (essentially all | |
5639 | the packages.) | |
5640 | ||
37166310 LC |
5641 | @item --update |
5642 | @itemx -u | |
38e16b49 LC |
5643 | Update distribution source files (package recipes) in place. This is |
5644 | usually run from a checkout of the Guix source tree (@pxref{Running | |
5645 | Guix Before It Is Installed}): | |
5646 | ||
5647 | @example | |
e9c72306 | 5648 | $ ./pre-inst-env guix refresh -s non-core -u |
38e16b49 LC |
5649 | @end example |
5650 | ||
081145cf | 5651 | @xref{Defining Packages}, for more information on package definitions. |
37166310 LC |
5652 | |
5653 | @item --select=[@var{subset}] | |
5654 | @itemx -s @var{subset} | |
5655 | Select all the packages in @var{subset}, one of @code{core} or | |
5656 | @code{non-core}. | |
5657 | ||
5658 | The @code{core} subset refers to all the packages at the core of the | |
5659 | distribution---i.e., packages that are used to build ``everything | |
5660 | else''. This includes GCC, libc, Binutils, Bash, etc. Usually, | |
5661 | changing one of these packages in the distribution entails a rebuild of | |
5662 | all the others. Thus, such updates are an inconvenience to users in | |
5663 | terms of build time or bandwidth used to achieve the upgrade. | |
5664 | ||
5665 | The @code{non-core} subset refers to the remaining packages. It is | |
5666 | typically useful in cases where an update of the core packages would be | |
5667 | inconvenient. | |
5668 | ||
bcb571cb LC |
5669 | @item --type=@var{updater} |
5670 | @itemx -t @var{updater} | |
7191adc5 AK |
5671 | Select only packages handled by @var{updater} (may be a comma-separated |
5672 | list of updaters). Currently, @var{updater} may be one of: | |
bcb571cb LC |
5673 | |
5674 | @table @code | |
5675 | @item gnu | |
5676 | the updater for GNU packages; | |
e80c0f85 LC |
5677 | @item gnome |
5678 | the updater for GNOME packages; | |
9c97afe8 DC |
5679 | @item kde |
5680 | the updater for KDE packages; | |
62061d6b AW |
5681 | @item xorg |
5682 | the updater for X.org packages; | |
2fd370e8 LC |
5683 | @item kernel.org |
5684 | the updater for packages hosted on kernel.org; | |
bcb571cb | 5685 | @item elpa |
d882c235 LC |
5686 | the updater for @uref{http://elpa.gnu.org/, ELPA} packages; |
5687 | @item cran | |
b9d044ef | 5688 | the updater for @uref{http://cran.r-project.org/, CRAN} packages; |
d0bd632f RW |
5689 | @item bioconductor |
5690 | the updater for @uref{http://www.bioconductor.org/, Bioconductor} R packages; | |
200cdf81 EB |
5691 | @item cpan |
5692 | the updater for @uref{http://www.cpan.org/, CPAN} packages; | |
bab020d7 | 5693 | @item pypi |
b9d044ef | 5694 | the updater for @uref{https://pypi.python.org, PyPI} packages. |
fbc5b815 BW |
5695 | @item gem |
5696 | the updater for @uref{https://rubygems.org, RubyGems} packages. | |
917a2a58 BW |
5697 | @item github |
5698 | the updater for @uref{https://github.com, GitHub} packages. | |
42efe27a EB |
5699 | @item hackage |
5700 | the updater for @uref{https://hackage.haskell.org, Hackage} packages. | |
bc5844d1 FB |
5701 | @item stackage |
5702 | the updater for @uref{https://www.stackage.org, Stackage} packages. | |
8ac52987 DC |
5703 | @item crate |
5704 | the updater for @uref{https://crates.io, Crates} packages. | |
bcb571cb LC |
5705 | @end table |
5706 | ||
f97c9175 AE |
5707 | For instance, the following command only checks for updates of Emacs |
5708 | packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages: | |
bcb571cb LC |
5709 | |
5710 | @example | |
7191adc5 | 5711 | $ guix refresh --type=elpa,cran |
d882c235 | 5712 | gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0 |
bcb571cb LC |
5713 | gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9 |
5714 | @end example | |
5715 | ||
37166310 LC |
5716 | @end table |
5717 | ||
5718 | In addition, @command{guix refresh} can be passed one or more package | |
5719 | names, as in this example: | |
5720 | ||
5721 | @example | |
e9c72306 | 5722 | $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8 |
37166310 LC |
5723 | @end example |
5724 | ||
5725 | @noindent | |
5726 | The command above specifically updates the @code{emacs} and | |
5727 | @code{idutils} packages. The @code{--select} option would have no | |
5728 | effect in this case. | |
5729 | ||
7d193ec3 EB |
5730 | When considering whether to upgrade a package, it is sometimes |
5731 | convenient to know which packages would be affected by the upgrade and | |
5732 | should be checked for compatibility. For this the following option may | |
5733 | be used when passing @command{guix refresh} one or more package names: | |
5734 | ||
5735 | @table @code | |
5736 | ||
6ffa706b AK |
5737 | @item --list-updaters |
5738 | @itemx -L | |
5739 | List available updaters and exit (see @option{--type} above.) | |
5740 | ||
3676f892 LC |
5741 | For each updater, display the fraction of packages it covers; at the |
5742 | end, display the fraction of packages covered by all these updaters. | |
5743 | ||
7d193ec3 EB |
5744 | @item --list-dependent |
5745 | @itemx -l | |
5746 | List top-level dependent packages that would need to be rebuilt as a | |
5747 | result of upgrading one or more packages. | |
5748 | ||
b96a0640 LC |
5749 | @xref{Invoking guix graph, the @code{reverse-package} type of |
5750 | @command{guix graph}}, for information on how to visualize the list of | |
5751 | dependents of a package. | |
5752 | ||
7d193ec3 EB |
5753 | @end table |
5754 | ||
5755 | Be aware that the @code{--list-dependent} option only | |
5756 | @emph{approximates} the rebuilds that would be required as a result of | |
5757 | an upgrade. More rebuilds might be required under some circumstances. | |
5758 | ||
5759 | @example | |
7779ab61 LC |
5760 | $ guix refresh --list-dependent flex |
5761 | Building the following 120 packages would ensure 213 dependent packages are rebuilt: | |
5762 | hop-2.4.0 geiser-0.4 notmuch-0.18 mu-0.9.9.5 cflow-1.4 idutils-4.6 @dots{} | |
7d193ec3 EB |
5763 | @end example |
5764 | ||
5765 | The command above lists a set of packages that could be built to check | |
5766 | for compatibility with an upgraded @code{flex} package. | |
5767 | ||
f9230085 LC |
5768 | The following options can be used to customize GnuPG operation: |
5769 | ||
5770 | @table @code | |
5771 | ||
f9230085 LC |
5772 | @item --gpg=@var{command} |
5773 | Use @var{command} as the GnuPG 2.x command. @var{command} is searched | |
5774 | for in @code{$PATH}. | |
5775 | ||
2bc53ba9 LC |
5776 | @item --key-download=@var{policy} |
5777 | Handle missing OpenPGP keys according to @var{policy}, which may be one | |
5778 | of: | |
5779 | ||
5780 | @table @code | |
5781 | @item always | |
5782 | Always download missing OpenPGP keys from the key server, and add them | |
5783 | to the user's GnuPG keyring. | |
5784 | ||
5785 | @item never | |
5786 | Never try to download missing OpenPGP keys. Instead just bail out. | |
5787 | ||
5788 | @item interactive | |
5789 | When a package signed with an unknown OpenPGP key is encountered, ask | |
5790 | the user whether to download it or not. This is the default behavior. | |
5791 | @end table | |
5792 | ||
5793 | @item --key-server=@var{host} | |
5794 | Use @var{host} as the OpenPGP key server when importing a public key. | |
5795 | ||
f9230085 LC |
5796 | @end table |
5797 | ||
917a2a58 BW |
5798 | The @code{github} updater uses the |
5799 | @uref{https://developer.github.com/v3/, GitHub API} to query for new | |
5800 | releases. When used repeatedly e.g. when refreshing all packages, | |
5801 | GitHub will eventually refuse to answer any further API requests. By | |
5802 | default 60 API requests per hour are allowed, and a full refresh on all | |
5803 | GitHub packages in Guix requires more than this. Authentication with | |
5804 | GitHub through the use of an API token alleviates these limits. To use | |
5805 | an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a | |
5806 | token procured from @uref{https://github.com/settings/tokens} or | |
5807 | otherwise. | |
5808 | ||
5809 | ||
b4f5e0e8 CR |
5810 | @node Invoking guix lint |
5811 | @section Invoking @command{guix lint} | |
e32171ee JD |
5812 | |
5813 | @cindex @command{guix lint} | |
5814 | @cindex package, checking for errors | |
f97c9175 AE |
5815 | The @command{guix lint} command is meant to help package developers avoid |
5816 | common errors and use a consistent style. It runs a number of checks on | |
5817 | a given set of packages in order to find common mistakes in their | |
873c4085 LC |
5818 | definitions. Available @dfn{checkers} include (see |
5819 | @code{--list-checkers} for a complete list): | |
5820 | ||
5821 | @table @code | |
5822 | @item synopsis | |
5823 | @itemx description | |
5824 | Validate certain typographical and stylistic rules about package | |
5825 | descriptions and synopses. | |
5826 | ||
5827 | @item inputs-should-be-native | |
5828 | Identify inputs that should most likely be native inputs. | |
5829 | ||
5830 | @item source | |
5831 | @itemx home-page | |
fac46e3f | 5832 | @itemx mirror-url |
50f5c46d | 5833 | @itemx source-file-name |
873c4085 | 5834 | Probe @code{home-page} and @code{source} URLs and report those that are |
fac46e3f LC |
5835 | invalid. Suggest a @code{mirror://} URL when applicable. Check that |
5836 | the source file name is meaningful, e.g. is not | |
f97c9175 AE |
5837 | just a version number or ``git-checkout'', without a declared |
5838 | @code{file-name} (@pxref{origin Reference}). | |
40a7d4e5 | 5839 | |
5432734b | 5840 | @item cve |
09866b39 LC |
5841 | @cindex security vulnerabilities |
5842 | @cindex CVE, Common Vulnerabilities and Exposures | |
5432734b | 5843 | Report known vulnerabilities found in the Common Vulnerabilities and |
09866b39 | 5844 | Exposures (CVE) databases of the current and past year |
5432734b LC |
5845 | @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US |
5846 | NIST}. | |
5847 | ||
09866b39 LC |
5848 | To view information about a particular vulnerability, visit pages such as: |
5849 | ||
5850 | @itemize | |
5851 | @item | |
5852 | @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD} | |
5853 | @item | |
5854 | @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD} | |
5855 | @end itemize | |
5856 | ||
5857 | @noindent | |
5858 | where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g., | |
5859 | @code{CVE-2015-7554}. | |
5860 | ||
99effc8f LC |
5861 | Package developers can specify in package recipes the |
5862 | @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)} | |
5863 | name and version of the package when they differ from the name that Guix | |
5864 | uses, as in this example: | |
5865 | ||
5866 | @example | |
5867 | (package | |
5868 | (name "grub") | |
5869 | ;; @dots{} | |
5870 | ;; CPE calls this package "grub2". | |
5871 | (properties '((cpe-name . "grub2")))) | |
5872 | @end example | |
5873 | ||
40a7d4e5 LC |
5874 | @item formatting |
5875 | Warn about obvious source code formatting issues: trailing white space, | |
5876 | use of tabulations, etc. | |
873c4085 | 5877 | @end table |
b4f5e0e8 CR |
5878 | |
5879 | The general syntax is: | |
5880 | ||
5881 | @example | |
5882 | guix lint @var{options} @var{package}@dots{} | |
5883 | @end example | |
5884 | ||
5885 | If no package is given on the command line, then all packages are checked. | |
5886 | The @var{options} may be zero or more of the following: | |
5887 | ||
5888 | @table @code | |
f97c9175 AE |
5889 | @item --list-checkers |
5890 | @itemx -l | |
5891 | List and describe all the available checkers that will be run on packages | |
5892 | and exit. | |
b4f5e0e8 | 5893 | |
dd7c013d CR |
5894 | @item --checkers |
5895 | @itemx -c | |
5896 | Only enable the checkers specified in a comma-separated list using the | |
5897 | names returned by @code{--list-checkers}. | |
5898 | ||
b4f5e0e8 | 5899 | @end table |
37166310 | 5900 | |
fcc58db6 LC |
5901 | @node Invoking guix size |
5902 | @section Invoking @command{guix size} | |
5903 | ||
e32171ee JD |
5904 | @cindex size |
5905 | @cindex package size | |
5906 | @cindex closure | |
5907 | @cindex @command{guix size} | |
fcc58db6 LC |
5908 | The @command{guix size} command helps package developers profile the |
5909 | disk usage of packages. It is easy to overlook the impact of an | |
5910 | additional dependency added to a package, or the impact of using a | |
5911 | single output for a package that could easily be split (@pxref{Packages | |
f97c9175 | 5912 | with Multiple Outputs}). Such are the typical issues that |
fcc58db6 LC |
5913 | @command{guix size} can highlight. |
5914 | ||
e1a65ae5 | 5915 | The command can be passed a package specification such as @code{gcc@@4.8} |
fcc58db6 LC |
5916 | or @code{guile:debug}, or a file name in the store. Consider this |
5917 | example: | |
5918 | ||
5919 | @example | |
5920 | $ guix size coreutils | |
5921 | store item total self | |
5922 | /gnu/store/@dots{}-coreutils-8.23 70.0 13.9 19.8% | |
5923 | /gnu/store/@dots{}-gmp-6.0.0a 55.3 2.5 3.6% | |
5924 | /gnu/store/@dots{}-acl-2.2.52 53.7 0.5 0.7% | |
5925 | /gnu/store/@dots{}-attr-2.4.46 53.2 0.3 0.5% | |
5926 | /gnu/store/@dots{}-gcc-4.8.4-lib 52.9 15.7 22.4% | |
5927 | /gnu/store/@dots{}-glibc-2.21 37.2 37.2 53.1% | |
5928 | @end example | |
5929 | ||
5930 | @cindex closure | |
5931 | The store items listed here constitute the @dfn{transitive closure} of | |
5932 | Coreutils---i.e., Coreutils and all its dependencies, recursively---as | |
5933 | would be returned by: | |
5934 | ||
5935 | @example | |
5936 | $ guix gc -R /gnu/store/@dots{}-coreutils-8.23 | |
5937 | @end example | |
5938 | ||
f97c9175 | 5939 | Here the output shows three columns next to store items. The first column, |
fcc58db6 LC |
5940 | labeled ``total'', shows the size in mebibytes (MiB) of the closure of |
5941 | the store item---that is, its own size plus the size of all its | |
5942 | dependencies. The next column, labeled ``self'', shows the size of the | |
f97c9175 AE |
5943 | item itself. The last column shows the ratio of the size of the item |
5944 | itself to the space occupied by all the items listed here. | |
fcc58db6 LC |
5945 | |
5946 | In this example, we see that the closure of Coreutils weighs in at | |
5947 | 70@tie{}MiB, half of which is taken by libc. (That libc represents a | |
5948 | large fraction of the closure is not a problem @i{per se} because it is | |
5949 | always available on the system anyway.) | |
5950 | ||
5951 | When the package passed to @command{guix size} is available in the | |
5952 | store, @command{guix size} queries the daemon to determine its | |
5953 | dependencies, and measures its size in the store, similar to @command{du | |
5954 | -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU | |
5955 | Coreutils}). | |
5956 | ||
5957 | When the given package is @emph{not} in the store, @command{guix size} | |
f97c9175 AE |
5958 | reports information based on the available substitutes |
5959 | (@pxref{Substitutes}). This makes it possible it to profile disk usage of | |
5960 | store items that are not even on disk, only available remotely. | |
fcc58db6 | 5961 | |
db761534 LC |
5962 | You can also specify several package names: |
5963 | ||
5964 | @example | |
5965 | $ guix size coreutils grep sed bash | |
5966 | store item total self | |
5967 | /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4% | |
5968 | /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8% | |
5969 | /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6% | |
5970 | /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2% | |
5971 | @dots{} | |
5972 | total: 102.3 MiB | |
5973 | @end example | |
5974 | ||
5975 | @noindent | |
5976 | In this example we see that the combination of the four packages takes | |
5977 | 102.3@tie{}MiB in total, which is much less than the sum of each closure | |
5978 | since they have a lot of dependencies in common. | |
5979 | ||
a8f996c6 | 5980 | The available options are: |
fcc58db6 LC |
5981 | |
5982 | @table @option | |
5983 | ||
d490d06e LC |
5984 | @item --substitute-urls=@var{urls} |
5985 | Use substitute information from @var{urls}. | |
5986 | @xref{client-substitute-urls, the same option for @code{guix build}}. | |
5987 | ||
a8f996c6 | 5988 | @item --map-file=@var{file} |
f97c9175 | 5989 | Write a graphical map of disk usage in PNG format to @var{file}. |
a8f996c6 LC |
5990 | |
5991 | For the example above, the map looks like this: | |
5992 | ||
5993 | @image{images/coreutils-size-map,5in,, map of Coreutils disk usage | |
5994 | produced by @command{guix size}} | |
5995 | ||
5996 | This option requires that | |
5997 | @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be | |
5998 | installed and visible in Guile's module search path. When that is not | |
5999 | the case, @command{guix size} fails as it tries to load it. | |
6000 | ||
fcc58db6 LC |
6001 | @item --system=@var{system} |
6002 | @itemx -s @var{system} | |
6003 | Consider packages for @var{system}---e.g., @code{x86_64-linux}. | |
6004 | ||
6005 | @end table | |
6006 | ||
88856916 LC |
6007 | @node Invoking guix graph |
6008 | @section Invoking @command{guix graph} | |
6009 | ||
6010 | @cindex DAG | |
e32171ee JD |
6011 | @cindex @command{guix graph} |
6012 | @cindex package dependencies | |
88856916 LC |
6013 | Packages and their dependencies form a @dfn{graph}, specifically a |
6014 | directed acyclic graph (DAG). It can quickly become difficult to have a | |
f97c9175 | 6015 | mental model of the package DAG, so the @command{guix graph} command |
9ea36197 LC |
6016 | provides a visual representation of the DAG. By default, |
6017 | @command{guix graph} emits a DAG representation in the input format of | |
88856916 | 6018 | @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed |
9ea36197 LC |
6019 | directly to the @command{dot} command of Graphviz. It can also emit an |
6020 | HTML page with embedded JavaScript code to display a ``chord diagram'' | |
6021 | in a Web browser, using the @uref{https://d3js.org/, d3.js} library. | |
6022 | The general syntax is: | |
88856916 LC |
6023 | |
6024 | @example | |
6025 | guix graph @var{options} @var{package}@dots{} | |
6026 | @end example | |
6027 | ||
6028 | For example, the following command generates a PDF file representing the | |
6029 | package DAG for the GNU@tie{}Core Utilities, showing its build-time | |
6030 | dependencies: | |
6031 | ||
6032 | @example | |
6033 | guix graph coreutils | dot -Tpdf > dag.pdf | |
6034 | @end example | |
6035 | ||
6036 | The output looks like this: | |
6037 | ||
6038 | @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils} | |
6039 | ||
6040 | Nice little graph, no? | |
6041 | ||
f97c9175 | 6042 | But there is more than one graph! The one above is concise: it is the |
88856916 | 6043 | graph of package objects, omitting implicit inputs such as GCC, libc, |
f97c9175 AE |
6044 | grep, etc. It is often useful to have such a concise graph, but |
6045 | sometimes one may want to see more details. @command{guix graph} supports | |
6046 | several types of graphs, allowing you to choose the level of detail: | |
88856916 LC |
6047 | |
6048 | @table @code | |
6049 | @item package | |
f97c9175 | 6050 | This is the default type used in the example above. It shows the DAG of |
88856916 LC |
6051 | package objects, excluding implicit dependencies. It is concise, but |
6052 | filters out many details. | |
6053 | ||
b96a0640 LC |
6054 | @item reverse-package |
6055 | This shows the @emph{reverse} DAG of packages. For example: | |
6056 | ||
6057 | @example | |
6058 | guix graph --type=reverse-package ocaml | |
6059 | @end example | |
6060 | ||
6061 | ... yields the graph of packages that depend on OCaml. | |
6062 | ||
6063 | Note that for core packages this can yield huge graphs. If all you want | |
6064 | is to know the number of packages that depend on a given package, use | |
6065 | @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh, | |
6066 | @option{--list-dependent}}). | |
6067 | ||
88856916 LC |
6068 | @item bag-emerged |
6069 | This is the package DAG, @emph{including} implicit inputs. | |
6070 | ||
6071 | For instance, the following command: | |
6072 | ||
6073 | @example | |
6074 | guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf | |
6075 | @end example | |
6076 | ||
6077 | ... yields this bigger graph: | |
6078 | ||
6079 | @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils} | |
6080 | ||
6081 | At the bottom of the graph, we see all the implicit inputs of | |
6082 | @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}). | |
6083 | ||
f97c9175 | 6084 | Now, note that the dependencies of these implicit inputs---that is, the |
88856916 LC |
6085 | @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown |
6086 | here, for conciseness. | |
6087 | ||
6088 | @item bag | |
6089 | Similar to @code{bag-emerged}, but this time including all the bootstrap | |
6090 | dependencies. | |
6091 | ||
38b92daa LC |
6092 | @item bag-with-origins |
6093 | Similar to @code{bag}, but also showing origins and their dependencies. | |
6094 | ||
88856916 LC |
6095 | @item derivations |
6096 | This is the most detailed representation: It shows the DAG of | |
6097 | derivations (@pxref{Derivations}) and plain store items. Compared to | |
6098 | the above representation, many additional nodes are visible, including | |
f97c9175 | 6099 | build scripts, patches, Guile modules, etc. |
88856916 | 6100 | |
a773c314 LC |
6101 | For this type of graph, it is also possible to pass a @file{.drv} file |
6102 | name instead of a package name, as in: | |
6103 | ||
6104 | @example | |
6105 | guix graph -t derivation `guix system build -d my-config.scm` | |
6106 | @end example | |
88856916 LC |
6107 | @end table |
6108 | ||
f97c9175 | 6109 | All the types above correspond to @emph{build-time dependencies}. The |
88856916 LC |
6110 | following graph type represents the @emph{run-time dependencies}: |
6111 | ||
6112 | @table @code | |
6113 | @item references | |
6114 | This is the graph of @dfn{references} of a package output, as returned | |
6115 | by @command{guix gc --references} (@pxref{Invoking guix gc}). | |
6116 | ||
6117 | If the given package output is not available in the store, @command{guix | |
6118 | graph} attempts to obtain dependency information from substitutes. | |
a773c314 LC |
6119 | |
6120 | Here you can also pass a store file name instead of a package name. For | |
6121 | example, the command below produces the reference graph of your profile | |
6122 | (which can be big!): | |
6123 | ||
6124 | @example | |
6125 | guix graph -t references `readlink -f ~/.guix-profile` | |
6126 | @end example | |
7f8fec0f LC |
6127 | |
6128 | @item referrers | |
6129 | This is the graph of the @dfn{referrers} of a store item, as returned by | |
6130 | @command{guix gc --referrers} (@pxref{Invoking guix gc}). | |
6131 | ||
6132 | This relies exclusively on local information from your store. For | |
6133 | instance, let us suppose that the current Inkscape is available in 10 | |
6134 | profiles on your machine; @command{guix graph -t referrers inkscape} | |
6135 | will show a graph rooted at Inkscape and with those 10 profiles linked | |
6136 | to it. | |
6137 | ||
6138 | It can help determine what is preventing a store item from being garbage | |
6139 | collected. | |
6140 | ||
88856916 LC |
6141 | @end table |
6142 | ||
6143 | The available options are the following: | |
6144 | ||
6145 | @table @option | |
6146 | @item --type=@var{type} | |
6147 | @itemx -t @var{type} | |
6148 | Produce a graph output of @var{type}, where @var{type} must be one of | |
6149 | the values listed above. | |
6150 | ||
6151 | @item --list-types | |
6152 | List the supported graph types. | |
4c8f997a | 6153 | |
642339dc RW |
6154 | @item --backend=@var{backend} |
6155 | @itemx -b @var{backend} | |
6156 | Produce a graph using the selected @var{backend}. | |
6157 | ||
6158 | @item --list-backends | |
6159 | List the supported graph backends. | |
6160 | ||
9ea36197 LC |
6161 | Currently, the available backends are Graphviz and d3.js. |
6162 | ||
4c8f997a LC |
6163 | @item --expression=@var{expr} |
6164 | @itemx -e @var{expr} | |
6165 | Consider the package @var{expr} evaluates to. | |
6166 | ||
6167 | This is useful to precisely refer to a package, as in this example: | |
6168 | ||
6169 | @example | |
6170 | guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)' | |
6171 | @end example | |
88856916 LC |
6172 | @end table |
6173 | ||
6174 | ||
372c4bbc DT |
6175 | @node Invoking guix environment |
6176 | @section Invoking @command{guix environment} | |
6177 | ||
f5fd4fd2 | 6178 | @cindex reproducible build environments |
fe36d84e | 6179 | @cindex development environments |
e32171ee JD |
6180 | @cindex @command{guix environment} |
6181 | @cindex environment, package build environment | |
372c4bbc DT |
6182 | The purpose of @command{guix environment} is to assist hackers in |
6183 | creating reproducible development environments without polluting their | |
6184 | package profile. The @command{guix environment} tool takes one or more | |
f97c9175 | 6185 | packages, builds all of their inputs, and creates a shell |
372c4bbc DT |
6186 | environment to use them. |
6187 | ||
6188 | The general syntax is: | |
6189 | ||
6190 | @example | |
6191 | guix environment @var{options} @var{package}@dots{} | |
6192 | @end example | |
6193 | ||
fe36d84e LC |
6194 | The following example spawns a new shell set up for the development of |
6195 | GNU@tie{}Guile: | |
372c4bbc DT |
6196 | |
6197 | @example | |
6198 | guix environment guile | |
6199 | @end example | |
6200 | ||
f97c9175 AE |
6201 | If the needed dependencies are not built yet, @command{guix environment} |
6202 | automatically builds them. The environment of the new shell is an augmented | |
372c4bbc DT |
6203 | version of the environment that @command{guix environment} was run in. |
6204 | It contains the necessary search paths for building the given package | |
6205 | added to the existing environment variables. To create a ``pure'' | |
f97c9175 | 6206 | environment, in which the original environment variables have been unset, |
50500f7c LC |
6207 | use the @code{--pure} option@footnote{Users sometimes wrongfully augment |
6208 | environment variables such as @code{PATH} in their @file{~/.bashrc} | |
6209 | file. As a consequence, when @code{guix environment} launches it, Bash | |
6210 | may read @file{~/.bashrc}, thereby introducing ``impurities'' in these | |
6211 | environment variables. It is an error to define such environment | |
6212 | variables in @file{.bashrc}; instead, they should be defined in | |
6213 | @file{.bash_profile}, which is sourced only by log-in shells. | |
6214 | @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for | |
6215 | details on Bash start-up files.}. | |
372c4bbc | 6216 | |
28de8d25 LC |
6217 | @vindex GUIX_ENVIRONMENT |
6218 | @command{guix environment} defines the @code{GUIX_ENVIRONMENT} | |
20185522 LC |
6219 | variable in the shell it spawns; its value is the file name of the |
6220 | profile of this environment. This allows users to, say, define a | |
28de8d25 LC |
6221 | specific prompt for development environments in their @file{.bashrc} |
6222 | (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}): | |
6223 | ||
6224 | @example | |
6225 | if [ -n "$GUIX_ENVIRONMENT" ] | |
6226 | then | |
6227 | export PS1="\u@@\h \w [dev]\$ " | |
6228 | fi | |
6229 | @end example | |
6230 | ||
20185522 LC |
6231 | @noindent |
6232 | ... or to browse the profile: | |
6233 | ||
6234 | @example | |
6235 | $ ls "$GUIX_ENVIRONMENT/bin" | |
6236 | @end example | |
6237 | ||
372c4bbc DT |
6238 | Additionally, more than one package may be specified, in which case the |
6239 | union of the inputs for the given packages are used. For example, the | |
6240 | command below spawns a shell where all of the dependencies of both Guile | |
6241 | and Emacs are available: | |
6242 | ||
6243 | @example | |
6244 | guix environment guile emacs | |
6245 | @end example | |
6246 | ||
1de2fe95 DT |
6247 | Sometimes an interactive shell session is not desired. An arbitrary |
6248 | command may be invoked by placing the @code{--} token to separate the | |
6249 | command from the rest of the arguments: | |
372c4bbc DT |
6250 | |
6251 | @example | |
1de2fe95 | 6252 | guix environment guile -- make -j4 |
372c4bbc DT |
6253 | @end example |
6254 | ||
fe36d84e LC |
6255 | In other situations, it is more convenient to specify the list of |
6256 | packages needed in the environment. For example, the following command | |
6257 | runs @command{python} from an environment containing Python@tie{}2.7 and | |
6258 | NumPy: | |
6259 | ||
6260 | @example | |
1de2fe95 | 6261 | guix environment --ad-hoc python2-numpy python-2.7 -- python |
fe36d84e LC |
6262 | @end example |
6263 | ||
cc90fbbf DT |
6264 | Furthermore, one might want the dependencies of a package and also some |
6265 | additional packages that are not build-time or runtime dependencies, but | |
6266 | are useful when developing nonetheless. Because of this, the | |
6267 | @code{--ad-hoc} flag is positional. Packages appearing before | |
6268 | @code{--ad-hoc} are interpreted as packages whose dependencies will be | |
6269 | added to the environment. Packages appearing after are interpreted as | |
6270 | packages that will be added to the environment directly. For example, | |
6271 | the following command creates a Guix development environment that | |
6272 | additionally includes Git and strace: | |
6273 | ||
6274 | @example | |
6275 | guix environment guix --ad-hoc git strace | |
6276 | @end example | |
6277 | ||
f535dcbe DT |
6278 | Sometimes it is desirable to isolate the environment as much as |
6279 | possible, for maximal purity and reproducibility. In particular, when | |
6280 | using Guix on a host distro that is not GuixSD, it is desirable to | |
6281 | prevent access to @file{/usr/bin} and other system-wide resources from | |
6282 | the development environment. For example, the following command spawns | |
6283 | a Guile REPL in a ``container'' where only the store and the current | |
6284 | working directory are mounted: | |
6285 | ||
6286 | @example | |
6287 | guix environment --ad-hoc --container guile -- guile | |
6288 | @end example | |
6289 | ||
0f252e26 | 6290 | @quotation Note |
cfd35b4e | 6291 | The @code{--container} option requires Linux-libre 3.19 or newer. |
0f252e26 DT |
6292 | @end quotation |
6293 | ||
fe36d84e | 6294 | The available options are summarized below. |
372c4bbc DT |
6295 | |
6296 | @table @code | |
f943c317 LC |
6297 | @item --root=@var{file} |
6298 | @itemx -r @var{file} | |
6299 | @cindex persistent environment | |
6300 | @cindex garbage collector root, for environments | |
6301 | Make @var{file} a symlink to the profile for this environment, and | |
6302 | register it as a garbage collector root. | |
6303 | ||
6304 | This is useful if you want to protect your environment from garbage | |
6305 | collection, to make it ``persistent''. | |
6306 | ||
6307 | When this option is omitted, the environment is protected from garbage | |
6308 | collection only for the duration of the @command{guix environment} | |
6309 | session. This means that next time you recreate the same environment, | |
6310 | you could have to rebuild or re-download packages. | |
6311 | ||
372c4bbc DT |
6312 | @item --expression=@var{expr} |
6313 | @itemx -e @var{expr} | |
c9c282ce DT |
6314 | Create an environment for the package or list of packages that |
6315 | @var{expr} evaluates to. | |
372c4bbc | 6316 | |
fe36d84e LC |
6317 | For example, running: |
6318 | ||
6319 | @example | |
6320 | guix environment -e '(@@ (gnu packages maths) petsc-openmpi)' | |
6321 | @end example | |
6322 | ||
6323 | starts a shell with the environment for this specific variant of the | |
6324 | PETSc package. | |
6325 | ||
c9c282ce DT |
6326 | Running: |
6327 | ||
6328 | @example | |
5c2b2f00 | 6329 | guix environment --ad-hoc -e '(@@ (gnu) %base-packages)' |
c9c282ce DT |
6330 | @end example |
6331 | ||
6332 | starts a shell with all the GuixSD base packages available. | |
6333 | ||
fa445d64 | 6334 | The above commands only use the default output of the given packages. |
779aa003 DT |
6335 | To select other outputs, two element tuples can be specified: |
6336 | ||
6337 | @example | |
6338 | guix environment --ad-hoc -e '(list (@ (gnu packages bash) bash) "include")' | |
6339 | @end example | |
6340 | ||
372c4bbc DT |
6341 | @item --load=@var{file} |
6342 | @itemx -l @var{file} | |
c9c282ce DT |
6343 | Create an environment for the package or list of packages that the code |
6344 | within @var{file} evaluates to. | |
372c4bbc | 6345 | |
fe36d84e LC |
6346 | As an example, @var{file} might contain a definition like this |
6347 | (@pxref{Defining Packages}): | |
6348 | ||
6349 | @example | |
6350 | @verbatiminclude environment-gdb.scm | |
6351 | @end example | |
6352 | ||
a54bd6d7 DT |
6353 | @item --ad-hoc |
6354 | Include all specified packages in the resulting environment, as if an | |
6355 | @i{ad hoc} package were defined with them as inputs. This option is | |
6356 | useful for quickly creating an environment without having to write a | |
6357 | package expression to contain the desired inputs. | |
6358 | ||
6359 | For instance, the command: | |
6360 | ||
6361 | @example | |
1de2fe95 | 6362 | guix environment --ad-hoc guile guile-sdl -- guile |
a54bd6d7 DT |
6363 | @end example |
6364 | ||
6365 | runs @command{guile} in an environment where Guile and Guile-SDL are | |
6366 | available. | |
6367 | ||
417c39f1 | 6368 | Note that this example implicitly asks for the default output of |
f97c9175 | 6369 | @code{guile} and @code{guile-sdl}, but it is possible to ask for a |
417c39f1 LC |
6370 | specific output---e.g., @code{glib:bin} asks for the @code{bin} output |
6371 | of @code{glib} (@pxref{Packages with Multiple Outputs}). | |
6372 | ||
cc90fbbf DT |
6373 | This option may be composed with the default behavior of @command{guix |
6374 | environment}. Packages appearing before @code{--ad-hoc} are interpreted | |
6375 | as packages whose dependencies will be added to the environment, the | |
6376 | default behavior. Packages appearing after are interpreted as packages | |
6377 | that will be added to the environment directly. | |
6378 | ||
372c4bbc DT |
6379 | @item --pure |
6380 | Unset existing environment variables when building the new environment. | |
6381 | This has the effect of creating an environment in which search paths | |
6382 | only contain package inputs. | |
6383 | ||
6384 | @item --search-paths | |
6385 | Display the environment variable definitions that make up the | |
6386 | environment. | |
ce367ef3 LC |
6387 | |
6388 | @item --system=@var{system} | |
6389 | @itemx -s @var{system} | |
6390 | Attempt to build for @var{system}---e.g., @code{i686-linux}. | |
f535dcbe DT |
6391 | |
6392 | @item --container | |
6393 | @itemx -C | |
6394 | @cindex container | |
6395 | Run @var{command} within an isolated container. The current working | |
a01ad638 DT |
6396 | directory outside the container is mapped inside the container. |
6397 | Additionally, a dummy home directory is created that matches the current | |
6398 | user's home directory, and @file{/etc/passwd} is configured accordingly. | |
6399 | The spawned process runs as the current user outside the container, but | |
6400 | has root privileges in the context of the container. | |
f535dcbe DT |
6401 | |
6402 | @item --network | |
6403 | @itemx -N | |
6404 | For containers, share the network namespace with the host system. | |
6405 | Containers created without this flag only have access to the loopback | |
6406 | device. | |
6407 | ||
6408 | @item --expose=@var{source}[=@var{target}] | |
6409 | For containers, expose the file system @var{source} from the host system | |
6410 | as the read-only file system @var{target} within the container. If | |
6411 | @var{target} is not specified, @var{source} is used as the target mount | |
6412 | point in the container. | |
6413 | ||
6414 | The example below spawns a Guile REPL in a container in which the user's | |
6415 | home directory is accessible read-only via the @file{/exchange} | |
6416 | directory: | |
6417 | ||
6418 | @example | |
da31b9c7 | 6419 | guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile |
f535dcbe DT |
6420 | @end example |
6421 | ||
5c2b2f00 | 6422 | @item --share=@var{source}[=@var{target}] |
f535dcbe DT |
6423 | For containers, share the file system @var{source} from the host system |
6424 | as the writable file system @var{target} within the container. If | |
6425 | @var{target} is not specified, @var{source} is used as the target mount | |
6426 | point in the container. | |
6427 | ||
6428 | The example below spawns a Guile REPL in a container in which the user's | |
6429 | home directory is accessible for both reading and writing via the | |
6430 | @file{/exchange} directory: | |
6431 | ||
6432 | @example | |
da31b9c7 | 6433 | guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile |
f535dcbe | 6434 | @end example |
372c4bbc DT |
6435 | @end table |
6436 | ||
fdcb04af HG |
6437 | @command{guix environment} |
6438 | also supports all of the common build options that @command{guix | |
ccd7158d | 6439 | build} supports (@pxref{Common Build Options}). |
372c4bbc | 6440 | |
fdcb04af | 6441 | |
aff8ce7c DT |
6442 | @node Invoking guix publish |
6443 | @section Invoking @command{guix publish} | |
6444 | ||
e32171ee | 6445 | @cindex @command{guix publish} |
aff8ce7c | 6446 | The purpose of @command{guix publish} is to enable users to easily share |
f97c9175 | 6447 | their store with others, who can then use it as a substitute server |
8ce229fc LC |
6448 | (@pxref{Substitutes}). |
6449 | ||
6450 | When @command{guix publish} runs, it spawns an HTTP server which allows | |
6451 | anyone with network access to obtain substitutes from it. This means | |
6452 | that any machine running Guix can also act as if it were a build farm, | |
6453 | since the HTTP interface is compatible with Hydra, the software behind | |
6454 | the @code{hydra.gnu.org} build farm. | |
aff8ce7c DT |
6455 | |
6456 | For security, each substitute is signed, allowing recipients to check | |
6457 | their authenticity and integrity (@pxref{Substitutes}). Because | |
f97c9175 | 6458 | @command{guix publish} uses the signing key of the system, which is only |
5463fe51 LC |
6459 | readable by the system administrator, it must be started as root; the |
6460 | @code{--user} option makes it drop root privileges early on. | |
aff8ce7c | 6461 | |
b18812b6 LC |
6462 | The signing key pair must be generated before @command{guix publish} is |
6463 | launched, using @command{guix archive --generate-key} (@pxref{Invoking | |
6464 | guix archive}). | |
6465 | ||
aff8ce7c DT |
6466 | The general syntax is: |
6467 | ||
6468 | @example | |
6469 | guix publish @var{options}@dots{} | |
6470 | @end example | |
6471 | ||
6472 | Running @command{guix publish} without any additional arguments will | |
6473 | spawn an HTTP server on port 8080: | |
6474 | ||
6475 | @example | |
6476 | guix publish | |
6477 | @end example | |
6478 | ||
6479 | Once a publishing server has been authorized (@pxref{Invoking guix | |
6480 | archive}), the daemon may download substitutes from it: | |
6481 | ||
6482 | @example | |
6483 | guix-daemon --substitute-urls=http://example.org:8080 | |
6484 | @end example | |
6485 | ||
ff6638d1 LC |
6486 | As a bonus, @command{guix publish} also serves as a content-addressed |
6487 | mirror for source files referenced in @code{origin} records | |
6488 | (@pxref{origin Reference}). For instance, assuming @command{guix | |
6489 | publish} is running on @code{example.org}, the following URL returns the | |
6490 | raw @file{hello-2.10.tar.gz} file with the given SHA256 hash | |
6491 | (represented in @code{nix-base32} format, @pxref{Invoking guix hash}): | |
6492 | ||
6493 | @example | |
6494 | http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i | |
6495 | @end example | |
6496 | ||
6497 | Obviously, these URLs only work for files that are in the store; in | |
6498 | other cases, they return 404 (``Not Found''). | |
6499 | ||
aff8ce7c DT |
6500 | The following options are available: |
6501 | ||
6502 | @table @code | |
6503 | @item --port=@var{port} | |
6504 | @itemx -p @var{port} | |
6505 | Listen for HTTP requests on @var{port}. | |
6506 | ||
9e2292ef LC |
6507 | @item --listen=@var{host} |
6508 | Listen on the network interface for @var{host}. The default is to | |
6509 | accept connections from any interface. | |
6510 | ||
5463fe51 LC |
6511 | @item --user=@var{user} |
6512 | @itemx -u @var{user} | |
6513 | Change privileges to @var{user} as soon as possible---i.e., once the | |
6514 | server socket is open and the signing key has been read. | |
6515 | ||
4a1fc562 LC |
6516 | @item --compression[=@var{level}] |
6517 | @itemx -C [@var{level}] | |
6518 | Compress data using the given @var{level}. When @var{level} is zero, | |
6519 | disable compression. The range 1 to 9 corresponds to different gzip | |
6520 | compression levels: 1 is the fastest, and 9 is the best (CPU-intensive). | |
6521 | The default is 3. | |
6522 | ||
4591c02e | 6523 | Compression occurs on the fly and the compressed streams are not |
4a1fc562 LC |
6524 | cached. Thus, to reduce load on the machine that runs @command{guix |
6525 | publish}, it may be a good idea to choose a low compression level, or to | |
6526 | run @command{guix publish} behind a caching proxy. | |
6527 | ||
e4c7a5f7 LC |
6528 | @item --ttl=@var{ttl} |
6529 | Produce @code{Cache-Control} HTTP headers that advertise a time-to-live | |
6530 | (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5 | |
6531 | days, @code{1m} means 1 month, and so on. | |
6532 | ||
6533 | This allows the user's Guix to keep substitute information in cache for | |
6534 | @var{ttl}. However, note that @code{guix publish} does not itself | |
6535 | guarantee that the store items it provides will indeed remain available | |
6536 | for as long as @var{ttl}. | |
6537 | ||
4bb5e0ae LC |
6538 | @item --nar-path=@var{path} |
6539 | Use @var{path} as the prefix for the URLs of ``nar'' files | |
6540 | (@pxref{Invoking guix archive, normalized archives}). | |
6541 | ||
6542 | By default, nars are served at a URL such as | |
6543 | @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to | |
6544 | change the @code{/nar} part to @var{path}. | |
6545 | ||
46f58390 LC |
6546 | @item --public-key=@var{file} |
6547 | @itemx --private-key=@var{file} | |
6548 | Use the specific @var{file}s as the public/private key pair used to sign | |
6549 | the store items being published. | |
6550 | ||
6551 | The files must correspond to the same key pair (the private key is used | |
6552 | for signing and the public key is merely advertised in the signature | |
6553 | metadata). They must contain keys in the canonical s-expression format | |
6554 | as produced by @command{guix archive --generate-key} (@pxref{Invoking | |
6555 | guix archive}). By default, @file{/etc/guix/signing-key.pub} and | |
6556 | @file{/etc/guix/signing-key.sec} are used. | |
6557 | ||
aff8ce7c DT |
6558 | @item --repl[=@var{port}] |
6559 | @itemx -r [@var{port}] | |
6560 | Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile | |
8ce229fc LC |
6561 | Reference Manual}) on @var{port} (37146 by default). This is used |
6562 | primarily for debugging a running @command{guix publish} server. | |
aff8ce7c DT |
6563 | @end table |
6564 | ||
1c52181f | 6565 | Enabling @command{guix publish} on a GuixSD system is a one-liner: just |
f1e900a3 LC |
6566 | instantiate a @code{guix-publish-service-type} service in the @code{services} field |
6567 | of the @code{operating-system} declaration (@pxref{guix-publish-service-type, | |
6568 | @code{guix-publish-service-type}}). | |
1c52181f | 6569 | |
332d7903 HG |
6570 | If you are instead running Guix on a ``foreign distro'', follow these |
6571 | instructions:” | |
6572 | ||
6573 | @itemize | |
6574 | @item | |
6575 | If your host distro uses the systemd init system: | |
6576 | ||
6577 | @example | |
6578 | # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \ | |
6579 | /etc/systemd/system/ | |
6580 | # systemctl start guix-publish && systemctl enable guix-publish | |
6581 | @end example | |
6582 | ||
6583 | @item | |
6584 | If your host distro uses the Upstart init system: | |
6585 | ||
6586 | @example | |
6587 | # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/ | |
6588 | # start guix-publish | |
6589 | @end example | |
6590 | ||
6591 | @item | |
6592 | Otherwise, proceed similarly with your distro's init system. | |
6593 | @end itemize | |
d23c20f1 LC |
6594 | |
6595 | @node Invoking guix challenge | |
6596 | @section Invoking @command{guix challenge} | |
6597 | ||
6598 | @cindex reproducible builds | |
6599 | @cindex verifiable builds | |
e32171ee JD |
6600 | @cindex @command{guix challenge} |
6601 | @cindex challenge | |
d23c20f1 | 6602 | Do the binaries provided by this server really correspond to the source |
f97c9175 | 6603 | code it claims to build? Is a package build process deterministic? |
d23c20f1 LC |
6604 | These are the questions the @command{guix challenge} command attempts to |
6605 | answer. | |
6606 | ||
6607 | The former is obviously an important question: Before using a substitute | |
f97c9175 | 6608 | server (@pxref{Substitutes}), one had better @emph{verify} that it |
d23c20f1 LC |
6609 | provides the right binaries, and thus @emph{challenge} it. The latter |
6610 | is what enables the former: If package builds are deterministic, then | |
6611 | independent builds of the package should yield the exact same result, | |
6612 | bit for bit; if a server provides a binary different from the one | |
6613 | obtained locally, it may be either corrupt or malicious. | |
6614 | ||
6615 | We know that the hash that shows up in @file{/gnu/store} file names is | |
6616 | the hash of all the inputs of the process that built the file or | |
6617 | directory---compilers, libraries, build scripts, | |
6618 | etc. (@pxref{Introduction}). Assuming deterministic build processes, | |
6619 | one store file name should map to exactly one build output. | |
6620 | @command{guix challenge} checks whether there is, indeed, a single | |
6621 | mapping by comparing the build outputs of several independent builds of | |
6622 | any given store item. | |
6623 | ||
f97c9175 | 6624 | The command output looks like this: |
d23c20f1 LC |
6625 | |
6626 | @smallexample | |
ddbc7f7d LC |
6627 | $ guix challenge --substitute-urls="https://hydra.gnu.org https://guix.example.org" |
6628 | updating list of substitutes from 'https://hydra.gnu.org'... 100.0% | |
6629 | updating list of substitutes from 'https://guix.example.org'... 100.0% | |
d23c20f1 LC |
6630 | /gnu/store/@dots{}-openssl-1.0.2d contents differ: |
6631 | local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q | |
ddbc7f7d LC |
6632 | https://hydra.gnu.org/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q |
6633 | https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim | |
d23c20f1 LC |
6634 | /gnu/store/@dots{}-git-2.5.0 contents differ: |
6635 | local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha | |
ddbc7f7d LC |
6636 | https://hydra.gnu.org/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f |
6637 | https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73 | |
d23c20f1 LC |
6638 | /gnu/store/@dots{}-pius-2.1.1 contents differ: |
6639 | local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax | |
ddbc7f7d LC |
6640 | https://hydra.gnu.org/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax |
6641 | https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs | |
d23c20f1 LC |
6642 | @end smallexample |
6643 | ||
6644 | @noindent | |
6645 | In this example, @command{guix challenge} first scans the store to | |
6646 | determine the set of locally-built derivations---as opposed to store | |
6647 | items that were downloaded from a substitute server---and then queries | |
6648 | all the substitute servers. It then reports those store items for which | |
6649 | the servers obtained a result different from the local build. | |
6650 | ||
6651 | @cindex non-determinism, in package builds | |
6652 | As an example, @code{guix.example.org} always gets a different answer. | |
6653 | Conversely, @code{hydra.gnu.org} agrees with local builds, except in the | |
6654 | case of Git. This might indicate that the build process of Git is | |
6655 | non-deterministic, meaning that its output varies as a function of | |
6656 | various things that Guix does not fully control, in spite of building | |
6657 | packages in isolated environments (@pxref{Features}). Most common | |
6658 | sources of non-determinism include the addition of timestamps in build | |
6659 | results, the inclusion of random numbers, and directory listings sorted | |
a70a5004 | 6660 | by inode number. See @uref{https://reproducible-builds.org/docs/}, for |
d23c20f1 LC |
6661 | more information. |
6662 | ||
f97c9175 | 6663 | To find out what is wrong with this Git binary, we can do something along |
d23c20f1 LC |
6664 | these lines (@pxref{Invoking guix archive}): |
6665 | ||
6666 | @example | |
ddbc7f7d | 6667 | $ wget -q -O - https://hydra.gnu.org/nar/@dots{}-git-2.5.0 \ |
d23c20f1 | 6668 | | guix archive -x /tmp/git |
043f4698 | 6669 | $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git |
d23c20f1 LC |
6670 | @end example |
6671 | ||
6672 | This command shows the difference between the files resulting from the | |
6673 | local build, and the files resulting from the build on | |
6674 | @code{hydra.gnu.org} (@pxref{Overview, Comparing and Merging Files,, | |
6675 | diffutils, Comparing and Merging Files}). The @command{diff} command | |
6676 | works great for text files. When binary files differ, a better option | |
ddbc7f7d | 6677 | is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps |
d23c20f1 LC |
6678 | visualize differences for all kinds of files. |
6679 | ||
f97c9175 | 6680 | Once you have done that work, you can tell whether the differences are due |
d23c20f1 LC |
6681 | to a non-deterministic build process or to a malicious server. We try |
6682 | hard to remove sources of non-determinism in packages to make it easier | |
f97c9175 AE |
6683 | to verify substitutes, but of course, this is a process that |
6684 | involves not just Guix, but a large part of the free software community. | |
d23c20f1 LC |
6685 | In the meantime, @command{guix challenge} is one tool to help address |
6686 | the problem. | |
6687 | ||
6688 | If you are writing packages for Guix, you are encouraged to check | |
6689 | whether @code{hydra.gnu.org} and other substitute servers obtain the | |
6690 | same build result as you did with: | |
6691 | ||
6692 | @example | |
6693 | $ guix challenge @var{package} | |
6694 | @end example | |
6695 | ||
6696 | @noindent | |
f97c9175 | 6697 | where @var{package} is a package specification such as |
7cffaeb6 | 6698 | @code{guile@@2.0} or @code{glibc:debug}. |
d23c20f1 LC |
6699 | |
6700 | The general syntax is: | |
6701 | ||
6702 | @example | |
6703 | guix challenge @var{options} [@var{packages}@dots{}] | |
6704 | @end example | |
6705 | ||
7cffaeb6 LC |
6706 | When a difference is found between the hash of a locally-built item and |
6707 | that of a server-provided substitute, or among substitutes provided by | |
6708 | different servers, the command displays it as in the example above and | |
a17417a8 LC |
6709 | its exit code is 2 (other non-zero exit codes denote other kinds of |
6710 | errors.) | |
7cffaeb6 | 6711 | |
d23c20f1 LC |
6712 | The one option that matters is: |
6713 | ||
6714 | @table @code | |
6715 | ||
6716 | @item --substitute-urls=@var{urls} | |
6717 | Consider @var{urls} the whitespace-separated list of substitute source | |
6718 | URLs to compare to. | |
6719 | ||
153b6295 LC |
6720 | @item --verbose |
6721 | @itemx -v | |
6722 | Show details about matches (identical contents) in addition to | |
6723 | information about mismatches. | |
6724 | ||
d23c20f1 LC |
6725 | @end table |
6726 | ||
f11c444d LC |
6727 | @node Invoking guix copy |
6728 | @section Invoking @command{guix copy} | |
6729 | ||
6730 | @cindex copy, of store items, over SSH | |
6731 | @cindex SSH, copy of store items | |
6732 | @cindex sharing store items across machines | |
6733 | @cindex transferring store items across machines | |
6734 | The @command{guix copy} command copies items from the store of one | |
6735 | machine to that of another machine over a secure shell (SSH) | |
6736 | connection@footnote{This command is available only when Guile-SSH was | |
6737 | found. @xref{Requirements}, for details.}. For example, the following | |
6738 | command copies the @code{coreutils} package, the user's profile, and all | |
6739 | their dependencies over to @var{host}, logged in as @var{user}: | |
6740 | ||
6741 | @example | |
6742 | guix copy --to=@var{user}@@@var{host} \ | |
6743 | coreutils `readlink -f ~/.guix-profile` | |
6744 | @end example | |
6745 | ||
6746 | If some of the items to be copied are already present on @var{host}, | |
6747 | they are not actually sent. | |
6748 | ||
6749 | The command below retrieves @code{libreoffice} and @code{gimp} from | |
6750 | @var{host}, assuming they are available there: | |
6751 | ||
6752 | @example | |
6753 | guix copy --from=@var{host} libreoffice gimp | |
6754 | @end example | |
6755 | ||
6756 | The SSH connection is established using the Guile-SSH client, which is | |
6757 | compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and | |
6758 | @file{~/.ssh/config}, and uses the SSH agent for authentication. | |
6759 | ||
6760 | The key used to sign items that are sent must be accepted by the remote | |
6761 | machine. Likewise, the key used by the remote machine to sign items you | |
6762 | are retrieving must be in @file{/etc/guix/acl} so it is accepted by your | |
6763 | own daemon. @xref{Invoking guix archive}, for more information about | |
6764 | store item authentication. | |
6765 | ||
6766 | The general syntax is: | |
6767 | ||
6768 | @example | |
6769 | guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{} | |
6770 | @end example | |
6771 | ||
6772 | You must always specify one of the following options: | |
6773 | ||
6774 | @table @code | |
6775 | @item --to=@var{spec} | |
6776 | @itemx --from=@var{spec} | |
6777 | Specify the host to send to or receive from. @var{spec} must be an SSH | |
6778 | spec such as @code{example.org}, @code{charlie@@example.org}, or | |
6779 | @code{charlie@@example.org:2222}. | |
6780 | @end table | |
6781 | ||
6782 | The @var{items} can be either package names, such as @code{gimp}, or | |
6783 | store items, such as @file{/gnu/store/@dots{}-idutils-4.6}. | |
6784 | ||
6785 | When specifying the name of a package to send, it is first built if | |
6786 | needed, unless @option{--dry-run} was specified. Common build options | |
6787 | are supported (@pxref{Common Build Options}). | |
6788 | ||
d23c20f1 | 6789 | |
32efa254 DT |
6790 | @node Invoking guix container |
6791 | @section Invoking @command{guix container} | |
6792 | @cindex container | |
e32171ee | 6793 | @cindex @command{guix container} |
32efa254 DT |
6794 | @quotation Note |
6795 | As of version @value{VERSION}, this tool is experimental. The interface | |
6796 | is subject to radical change in the future. | |
6797 | @end quotation | |
6798 | ||
6799 | The purpose of @command{guix container} is to manipulate processes | |
6800 | running within an isolated environment, commonly known as a | |
46c36586 | 6801 | ``container'', typically created by the @command{guix environment} |
32efa254 DT |
6802 | (@pxref{Invoking guix environment}) and @command{guix system container} |
6803 | (@pxref{Invoking guix system}) commands. | |
6804 | ||
6805 | The general syntax is: | |
6806 | ||
6807 | @example | |
6808 | guix container @var{action} @var{options}@dots{} | |
6809 | @end example | |
6810 | ||
6811 | @var{action} specifies the operation to perform with a container, and | |
6812 | @var{options} specifies the context-specific arguments for the action. | |
6813 | ||
6814 | The following actions are available: | |
6815 | ||
6816 | @table @code | |
6817 | @item exec | |
6818 | Execute a command within the context of a running container. | |
6819 | ||
6820 | The syntax is: | |
6821 | ||
6822 | @example | |
6823 | guix container exec @var{pid} @var{program} @var{arguments}@dots{} | |
6824 | @end example | |
6825 | ||
6826 | @var{pid} specifies the process ID of the running container. | |
f97c9175 AE |
6827 | @var{program} specifies an executable file name within the root file |
6828 | system of the container. @var{arguments} are the additional options that | |
6829 | will be passed to @var{program}. | |
32efa254 DT |
6830 | |
6831 | The following command launches an interactive login shell inside a | |
6832 | GuixSD container, started by @command{guix system container}, and whose | |
6833 | process ID is 9001: | |
6834 | ||
6835 | @example | |
6836 | guix container exec 9001 /run/current-system/profile/bin/bash --login | |
6837 | @end example | |
6838 | ||
6839 | Note that the @var{pid} cannot be the parent process of a container. It | |
f97c9175 | 6840 | must be PID 1 of the container or one of its child processes. |
32efa254 DT |
6841 | |
6842 | @end table | |
6843 | ||
a1ba8475 LC |
6844 | @c ********************************************************************* |
6845 | @node GNU Distribution | |
6846 | @chapter GNU Distribution | |
6847 | ||
3ca2731c | 6848 | @cindex Guix System Distribution |
4705641f | 6849 | @cindex GuixSD |
3ca2731c LC |
6850 | Guix comes with a distribution of the GNU system consisting entirely of |
6851 | free software@footnote{The term ``free'' here refers to the | |
a1ba8475 | 6852 | @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to |
3ca2731c | 6853 | users of that software}.}. The |
35ed9306 LC |
6854 | distribution can be installed on its own (@pxref{System Installation}), |
6855 | but it is also possible to install Guix as a package manager on top of | |
6856 | an installed GNU/Linux system (@pxref{Installation}). To distinguish | |
3ca2731c | 6857 | between the two, we refer to the standalone distribution as the Guix |
4705641f | 6858 | System Distribution, or GuixSD. |
35ed9306 LC |
6859 | |
6860 | The distribution provides core GNU packages such as GNU libc, GCC, and | |
6861 | Binutils, as well as many GNU and non-GNU applications. The complete | |
6862 | list of available packages can be browsed | |
093ae1be | 6863 | @url{http://www.gnu.org/software/guix/packages,on-line} or by |
d03bb653 | 6864 | running @command{guix package} (@pxref{Invoking guix package}): |
a1ba8475 LC |
6865 | |
6866 | @example | |
e49951eb | 6867 | guix package --list-available |
a1ba8475 LC |
6868 | @end example |
6869 | ||
f97c9175 | 6870 | Our goal is to provide a practical 100% free software distribution of |
401c53c4 LC |
6871 | Linux-based and other variants of GNU, with a focus on the promotion and |
6872 | tight integration of GNU components, and an emphasis on programs and | |
6873 | tools that help users exert that freedom. | |
6874 | ||
3ca2731c | 6875 | Packages are currently available on the following platforms: |
c320011d LC |
6876 | |
6877 | @table @code | |
6878 | ||
6879 | @item x86_64-linux | |
6880 | Intel/AMD @code{x86_64} architecture, Linux-Libre kernel; | |
6881 | ||
6882 | @item i686-linux | |
6883 | Intel 32-bit architecture (IA32), Linux-Libre kernel; | |
6884 | ||
aa1e1947 | 6885 | @item armhf-linux |
aa725117 | 6886 | ARMv7-A architecture with hard float, Thumb-2 and NEON, |
f97c9175 AE |
6887 | using the EABI hard-float application binary interface (ABI), |
6888 | and Linux-Libre kernel. | |
aa1e1947 | 6889 | |
3b88f376 EF |
6890 | @item aarch64-linux |
6891 | little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is | |
be2ba697 | 6892 | currently in an experimental stage, with limited support. |
3b88f376 EF |
6893 | @xref{Contributing}, for how to help! |
6894 | ||
c320011d LC |
6895 | @item mips64el-linux |
6896 | little-endian 64-bit MIPS processors, specifically the Loongson series, | |
f97c9175 | 6897 | n32 ABI, and Linux-Libre kernel. |
c320011d LC |
6898 | |
6899 | @end table | |
6900 | ||
4705641f | 6901 | GuixSD itself is currently only available on @code{i686} and @code{x86_64}. |
3ca2731c | 6902 | |
c320011d LC |
6903 | @noindent |
6904 | For information on porting to other architectures or kernels, | |
f97c9175 | 6905 | @pxref{Porting}. |
c320011d | 6906 | |
401c53c4 | 6907 | @menu |
5af6de3e | 6908 | * System Installation:: Installing the whole operating system. |
35ed9306 | 6909 | * System Configuration:: Configuring the operating system. |
91ef73d4 | 6910 | * Installing Debugging Files:: Feeding the debugger. |
05962f29 | 6911 | * Security Updates:: Deploying security fixes quickly. |
401c53c4 | 6912 | * Package Modules:: Packages from the programmer's viewpoint. |
da7cabd4 | 6913 | * Packaging Guidelines:: Growing the distribution. |
401c53c4 | 6914 | * Bootstrapping:: GNU/Linux built from scratch. |
8b315a6d | 6915 | * Porting:: Targeting another platform or kernel. |
401c53c4 LC |
6916 | @end menu |
6917 | ||
6918 | Building this distribution is a cooperative effort, and you are invited | |
081145cf | 6919 | to join! @xref{Contributing}, for information about how you can help. |
401c53c4 | 6920 | |
5af6de3e LC |
6921 | @node System Installation |
6922 | @section System Installation | |
6923 | ||
e32171ee | 6924 | @cindex installing GuixSD |
3ca2731c | 6925 | @cindex Guix System Distribution |
c8b54374 | 6926 | This section explains how to install the Guix System Distribution (GuixSD) |
3ca2731c | 6927 | on a machine. The Guix package manager can |
35ed9306 LC |
6928 | also be installed on top of a running GNU/Linux system, |
6929 | @pxref{Installation}. | |
5af6de3e LC |
6930 | |
6931 | @ifinfo | |
9c18cf9b | 6932 | @quotation Note |
5af6de3e LC |
6933 | @c This paragraph is for people reading this from tty2 of the |
6934 | @c installation image. | |
1068f26b | 6935 | You are reading this documentation with an Info reader. For details on |
5af6de3e | 6936 | how to use it, hit the @key{RET} key (``return'' or ``enter'') on the |
de341e7c LC |
6937 | link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU |
6938 | Info}. Hit @kbd{l} afterwards to come back here. | |
9c18cf9b LC |
6939 | |
6940 | Alternately, run @command{info info} in another tty to keep the manual | |
6941 | available. | |
6942 | @end quotation | |
5af6de3e LC |
6943 | @end ifinfo |
6944 | ||
dedb8d5e | 6945 | @menu |
e3009f60 LC |
6946 | * Limitations:: What you can expect. |
6947 | * Hardware Considerations:: Supported hardware. | |
6948 | * USB Stick Installation:: Preparing the installation medium. | |
6949 | * Preparing for Installation:: Networking, partitioning, etc. | |
6950 | * Proceeding with the Installation:: The real thing. | |
c8b54374 | 6951 | * Installing GuixSD in a VM:: GuixSD playground. |
e3009f60 | 6952 | * Building the Installation Image:: How this comes to be. |
dedb8d5e LC |
6953 | @end menu |
6954 | ||
6955 | @node Limitations | |
8aaaae38 LC |
6956 | @subsection Limitations |
6957 | ||
4705641f | 6958 | As of version @value{VERSION}, the Guix System Distribution (GuixSD) is |
3ca2731c | 6959 | not production-ready. It may contain bugs and lack important |
8aaaae38 LC |
6960 | features. Thus, if you are looking for a stable production system that |
6961 | respects your freedom as a computer user, a good solution at this point | |
6962 | is to consider @url{http://www.gnu.org/distros/free-distros.html, one of | |
f97c9175 | 6963 | the more established GNU/Linux distributions}. We hope you can soon switch |
4705641f | 6964 | to the GuixSD without fear, of course. In the meantime, you can |
8aaaae38 LC |
6965 | also keep using your distribution and try out the package manager on top |
6966 | of it (@pxref{Installation}). | |
6967 | ||
6968 | Before you proceed with the installation, be aware of the following | |
6969 | noteworthy limitations applicable to version @value{VERSION}: | |
6970 | ||
6971 | @itemize | |
6972 | @item | |
6973 | The installation process does not include a graphical user interface and | |
6974 | requires familiarity with GNU/Linux (see the following subsections to | |
6975 | get a feel of what that means.) | |
6976 | ||
8aaaae38 | 6977 | @item |
dbcb0ab1 | 6978 | Support for the Logical Volume Manager (LVM) is missing. |
8aaaae38 LC |
6979 | |
6980 | @item | |
6981 | Few system services are currently supported out-of-the-box | |
6982 | (@pxref{Services}). | |
6983 | ||
6984 | @item | |
4018745a | 6985 | More than 5,000 packages are available, but you may |
8aaaae38 | 6986 | occasionally find that a useful package is missing. |
5fe01c2d LC |
6987 | |
6988 | @item | |
6989 | GNOME, Xfce, and Enlightenment are available (@pxref{Desktop Services}), | |
6990 | as well as a number of X11 window managers. However, some graphical | |
6991 | applications may be missing, as well as KDE. | |
8aaaae38 LC |
6992 | @end itemize |
6993 | ||
f97c9175 AE |
6994 | You have been warned! But more than a disclaimer, this is an invitation |
6995 | to report issues (and success stories!), and to join us in improving it. | |
8aaaae38 | 6996 | @xref{Contributing}, for more info. |
5af6de3e | 6997 | |
e3009f60 LC |
6998 | |
6999 | @node Hardware Considerations | |
7000 | @subsection Hardware Considerations | |
7001 | ||
7002 | @cindex hardware support on GuixSD | |
7003 | GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It | |
7004 | builds around the kernel Linux-libre, which means that only hardware for | |
e0b3f97e | 7005 | which free software drivers and firmware exist is supported. Nowadays, |
e3009f60 LC |
7006 | a wide range of off-the-shelf hardware is supported on |
7007 | GNU/Linux-libre---from keyboards to graphics cards to scanners and | |
7008 | Ethernet controllers. Unfortunately, there are still areas where | |
7009 | hardware vendors deny users control over their own computing, and such | |
7010 | hardware is not supported on GuixSD. | |
7011 | ||
7012 | @cindex WiFi, hardware support | |
e0b3f97e | 7013 | One of the main areas where free drivers or firmware are lacking is WiFi |
e3009f60 LC |
7014 | devices. WiFi devices known to work include those using Atheros chips |
7015 | (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre | |
52db41af EB |
7016 | driver, and those using Broadcom/AirForce chips (BCM43xx with |
7017 | Wireless-Core Revision 5), which corresponds to the @code{b43-open} | |
7018 | Linux-libre driver. Free firmware exists for both and is available | |
e3009f60 LC |
7019 | out-of-the-box on GuixSD, as part of @var{%base-firmware} |
7020 | (@pxref{operating-system Reference, @code{firmware}}). | |
7021 | ||
7022 | @cindex RYF, Respects Your Freedom | |
7023 | The @uref{https://www.fsf.org/, Free Software Foundation} runs | |
e0b3f97e | 7024 | @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a |
e3009f60 LC |
7025 | certification program for hardware products that respect your freedom |
7026 | and your privacy and ensure that you have control over your device. We | |
e0b3f97e | 7027 | encourage you to check the list of RYF-certified devices. |
e3009f60 LC |
7028 | |
7029 | Another useful resource is the @uref{https://www.h-node.org/, H-Node} | |
7030 | web site. It contains a catalog of hardware devices with information | |
7031 | about their support in GNU/Linux. | |
7032 | ||
7033 | ||
dedb8d5e | 7034 | @node USB Stick Installation |
5af6de3e LC |
7035 | @subsection USB Stick Installation |
7036 | ||
7037 | An installation image for USB sticks can be downloaded from | |
4705641f | 7038 | @indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz}, |
5af6de3e LC |
7039 | where @var{system} is one of: |
7040 | ||
7041 | @table @code | |
7042 | @item x86_64-linux | |
7043 | for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs; | |
7044 | ||
7045 | @item i686-linux | |
7046 | for a 32-bit GNU/Linux system on Intel-compatible CPUs. | |
7047 | @end table | |
7048 | ||
debc6360 LC |
7049 | @c start duplication of authentication part from ``Binary Installation'' |
7050 | Make sure to download the associated @file{.sig} file and to verify the | |
7051 | authenticity of the image against it, along these lines: | |
7052 | ||
7053 | @example | |
7054 | $ wget ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig | |
7055 | $ gpg --verify guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig | |
7056 | @end example | |
7057 | ||
7058 | If that command fails because you do not have the required public key, | |
7059 | then run this command to import it: | |
7060 | ||
7061 | @example | |
7062 | $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID} | |
7063 | @end example | |
7064 | ||
7065 | @noindent | |
7066 | and rerun the @code{gpg --verify} command. | |
7067 | @c end duplication | |
7068 | ||
5af6de3e LC |
7069 | This image contains a single partition with the tools necessary for an |
7070 | installation. It is meant to be copied @emph{as is} to a large-enough | |
7071 | USB stick. | |
7072 | ||
7073 | To copy the image to a USB stick, follow these steps: | |
7074 | ||
7075 | @enumerate | |
7076 | @item | |
7077 | Decompress the image using the @command{xz} command: | |
7078 | ||
7079 | @example | |
4705641f | 7080 | xz -d guixsd-usb-install-@value{VERSION}.@var{system}.xz |
5af6de3e LC |
7081 | @end example |
7082 | ||
7083 | @item | |
f97c9175 AE |
7084 | Insert a USB stick of 1@tie{}GiB or more into your machine, and determine |
7085 | its device name. Assuming that the USB stick is known as @file{/dev/sdX}, | |
5af6de3e LC |
7086 | copy the image with: |
7087 | ||
7088 | @example | |
4705641f | 7089 | dd if=guixsd-usb-install-@value{VERSION}.x86_64 of=/dev/sdX |
5af6de3e LC |
7090 | @end example |
7091 | ||
7092 | Access to @file{/dev/sdX} usually requires root privileges. | |
7093 | @end enumerate | |
7094 | ||
7095 | Once this is done, you should be able to reboot the system and boot from | |
7096 | the USB stick. The latter usually requires you to get in the BIOS' boot | |
7097 | menu, where you can choose to boot from the USB stick. | |
7098 | ||
c8b54374 VL |
7099 | @xref{Installing GuixSD in a VM}, if, instead, you would like to install |
7100 | GuixSD in a virtual machine (VM). | |
7101 | ||
dedb8d5e | 7102 | @node Preparing for Installation |
5af6de3e LC |
7103 | @subsection Preparing for Installation |
7104 | ||
7105 | Once you have successfully booted the image on the USB stick, you should | |
7106 | end up with a root prompt. Several console TTYs are configured and can | |
7107 | be used to run commands as root. TTY2 shows this documentation, | |
de341e7c LC |
7108 | browsable using the Info reader commands (@pxref{Top,,, info-stnd, |
7109 | Stand-alone GNU Info}). The installation system runs the GPM mouse | |
7110 | daemon, which allows you to select text with the left mouse button and | |
7111 | to paste it with the middle button. | |
5af6de3e | 7112 | |
ff925d37 LC |
7113 | @quotation Note |
7114 | Installation requires access to the Internet so that any missing | |
7115 | dependencies of your system configuration can be downloaded. See the | |
7116 | ``Networking'' section below. | |
7117 | @end quotation | |
7118 | ||
0e69cf67 LC |
7119 | The installation system includes many common tools needed for this task. |
7120 | But it is also a full-blown GuixSD system, which means that you can | |
7121 | install additional packages, should you need it, using @command{guix | |
7122 | package} (@pxref{Invoking guix package}). | |
7123 | ||
dedb8d5e | 7124 | @subsubsection Keyboard Layout |
5af6de3e | 7125 | |
dedb8d5e LC |
7126 | @cindex keyboard layout |
7127 | The installation image uses the US qwerty keyboard layout. If you want | |
7128 | to change it, you can use the @command{loadkeys} command. For example, | |
7129 | the following command selects the Dvorak keyboard layout: | |
5af6de3e | 7130 | |
dedb8d5e LC |
7131 | @example |
7132 | loadkeys dvorak | |
7133 | @end example | |
7134 | ||
7135 | See the files under @file{/run/current-system/profile/share/keymaps} for | |
7136 | a list of available keyboard layouts. Run @command{man loadkeys} for | |
7137 | more information. | |
7138 | ||
7139 | @subsubsection Networking | |
7140 | ||
7141 | Run the following command see what your network interfaces are called: | |
235cba85 LC |
7142 | |
7143 | @example | |
dedb8d5e | 7144 | ifconfig -a |
235cba85 LC |
7145 | @end example |
7146 | ||
1713c37f LC |
7147 | @noindent |
7148 | @dots{} or, using the GNU/Linux-specific @command{ip} command: | |
7149 | ||
7150 | @example | |
7151 | ip a | |
7152 | @end example | |
7153 | ||
95c559c1 | 7154 | @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20 |
dedb8d5e LC |
7155 | Wired interfaces have a name starting with @samp{e}; for example, the |
7156 | interface corresponding to the first on-board Ethernet controller is | |
7157 | called @samp{eno1}. Wireless interfaces have a name starting with | |
7158 | @samp{w}, like @samp{w1p2s0}. | |
7159 | ||
7160 | @table @asis | |
7161 | @item Wired connection | |
7162 | To configure a wired network run the following command, substituting | |
7163 | @var{interface} with the name of the wired interface you want to use. | |
7164 | ||
7165 | @example | |
7166 | ifconfig @var{interface} up | |
7167 | @end example | |
7168 | ||
7169 | @item Wireless connection | |
e32171ee JD |
7170 | @cindex wireless |
7171 | @cindex WiFi | |
dedb8d5e LC |
7172 | To configure wireless networking, you can create a configuration file |
7173 | for the @command{wpa_supplicant} configuration tool (its location is not | |
7174 | important) using one of the available text editors such as | |
7175 | @command{zile}: | |
7176 | ||
7177 | @example | |
7178 | zile wpa_supplicant.conf | |
7179 | @end example | |
7180 | ||
7181 | As an example, the following stanza can go to this file and will work | |
7182 | for many wireless networks, provided you give the actual SSID and | |
7183 | passphrase for the network you are connecting to: | |
7184 | ||
7185 | @example | |
7186 | network=@{ | |
ae768308 | 7187 | ssid="@var{my-ssid}" |
dedb8d5e LC |
7188 | key_mgmt=WPA-PSK |
7189 | psk="the network's secret passphrase" | |
7190 | @} | |
7191 | @end example | |
7192 | ||
7193 | Start the wireless service and run it in the background with the | |
7194 | following command (substitute @var{interface} with the name of the | |
7195 | network interface you want to use): | |
7196 | ||
7197 | @example | |
7198 | wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B | |
7199 | @end example | |
7200 | ||
641d0518 | 7201 | Run @command{man wpa_supplicant} for more information. |
dedb8d5e LC |
7202 | @end table |
7203 | ||
e32171ee | 7204 | @cindex DHCP |
dedb8d5e LC |
7205 | At this point, you need to acquire an IP address. On a network where IP |
7206 | addresses are automatically assigned @i{via} DHCP, you can run: | |
7207 | ||
7208 | @example | |
15650ac2 | 7209 | dhclient -v @var{interface} |
dedb8d5e | 7210 | @end example |
5af6de3e | 7211 | |
dedb8d5e LC |
7212 | Try to ping a server to see if networking is up and running: |
7213 | ||
7214 | @example | |
7215 | ping -c 3 gnu.org | |
7216 | @end example | |
5af6de3e LC |
7217 | |
7218 | Setting up network access is almost always a requirement because the | |
7219 | image does not contain all the software and tools that may be needed. | |
7220 | ||
dedb8d5e LC |
7221 | @subsubsection Disk Partitioning |
7222 | ||
7223 | Unless this has already been done, the next step is to partition, and | |
7224 | then format the target partition(s). | |
7225 | ||
7226 | The installation image includes several partitioning tools, including | |
7227 | Parted (@pxref{Overview,,, parted, GNU Parted User Manual}), | |
7228 | @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with | |
7229 | the partition layout you want: | |
7230 | ||
7231 | @example | |
7232 | cfdisk | |
7233 | @end example | |
7234 | ||
d918d79f SB |
7235 | If your disk uses the GUID Partition Table (GPT) format and you plan to |
7236 | install BIOS-based GRUB (which is the default), make sure a BIOS Boot | |
7237 | Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB | |
7238 | manual}). | |
7239 | ||
dedb8d5e LC |
7240 | Once you are done partitioning the target hard disk drive, you have to |
7241 | create a file system on the relevant partition(s)@footnote{Currently | |
b1a505ba DC |
7242 | GuixSD only supports ext4 and btrfs file systems. In particular, code |
7243 | that reads partition UUIDs and labels only works for these file system | |
7244 | types.}. | |
5af6de3e | 7245 | |
7ab44369 LC |
7246 | Preferably, assign partitions a label so that you can easily and |
7247 | reliably refer to them in @code{file-system} declarations (@pxref{File | |
7248 | Systems}). This is typically done using the @code{-L} option of | |
dedb8d5e LC |
7249 | @command{mkfs.ext4} and related commands. So, assuming the target root |
7250 | partition lives at @file{/dev/sda1}, a file system with the label | |
7251 | @code{my-root} can be created with: | |
7ab44369 | 7252 | |
dedb8d5e LC |
7253 | @example |
7254 | mkfs.ext4 -L my-root /dev/sda1 | |
7255 | @end example | |
dd816355 | 7256 | |
13fb1bd9 LC |
7257 | @cindex encrypted disk |
7258 | If you are instead planning to encrypt the root partition, you can use | |
7259 | the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html, | |
7260 | @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}}, | |
7261 | @code{man cryptsetup}} for more information.) Assuming you want to | |
7262 | store the root partition on @file{/dev/sda1}, the command sequence would | |
7263 | be along these lines: | |
6d6e6281 | 7264 | |
13fb1bd9 LC |
7265 | @example |
7266 | cryptsetup luksFormat /dev/sda1 | |
7267 | cryptsetup open --type luks /dev/sda1 my-partition | |
7268 | mkfs.ext4 -L my-root /dev/mapper/my-partition | |
7269 | @end example | |
5af6de3e | 7270 | |
dedb8d5e | 7271 | Once that is done, mount the target root partition under @file{/mnt} |
13fb1bd9 LC |
7272 | with a command like (again, assuming @code{my-root} is the label of the |
7273 | root partition): | |
83a17b62 | 7274 | |
dedb8d5e | 7275 | @example |
13fb1bd9 | 7276 | mount LABEL=my-root /mnt |
dedb8d5e | 7277 | @end example |
83a17b62 | 7278 | |
31b6cdf8 LC |
7279 | Finally, if you plan to use one or more swap partitions (@pxref{Memory |
7280 | Concepts, swap space,, libc, The GNU C Library Reference Manual}), make | |
7281 | sure to initialize them with @command{mkswap}. Assuming you have one | |
7282 | swap partition on @file{/dev/sda2}, you would run: | |
7283 | ||
7284 | @example | |
7285 | mkswap /dev/sda2 | |
b2ff76a0 | 7286 | swapon /dev/sda2 |
31b6cdf8 LC |
7287 | @end example |
7288 | ||
a4ca4362 CM |
7289 | Alternatively, you may use a swap file. For example, assuming that in |
7290 | the new system you want to use the file @file{/swapfile} as a swap file, | |
7291 | you would run@footnote{This example will work for many types of file | |
7292 | systems (e.g., ext4). However, for copy-on-write file systems (e.g., | |
7293 | btrfs), the required steps may be different. For details, see the | |
7294 | manual pages for @command{mkswap} and @command{swapon}.}: | |
7295 | ||
7296 | @example | |
7297 | # This is 10 GiB of swap space. Adjust "count" to change the size. | |
7298 | dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240 | |
7299 | # For security, make the file readable and writable only by root. | |
7300 | chmod 600 /mnt/swapfile | |
7301 | mkswap /mnt/swapfile | |
7302 | swapon /mnt/swapfile | |
7303 | @end example | |
7304 | ||
7305 | Note that if you have encrypted the root partition and created a swap | |
7306 | file in its file system as described above, then the encryption also | |
7307 | protects the swap file, just like any other file in that file system. | |
7308 | ||
dedb8d5e LC |
7309 | @node Proceeding with the Installation |
7310 | @subsection Proceeding with the Installation | |
83a17b62 | 7311 | |
dedb8d5e LC |
7312 | With the target partitions ready and the target root mounted on |
7313 | @file{/mnt}, we're ready to go. First, run: | |
5af6de3e | 7314 | |
dedb8d5e LC |
7315 | @example |
7316 | herd start cow-store /mnt | |
7317 | @end example | |
5af6de3e | 7318 | |
b397c0d5 LC |
7319 | This makes @file{/gnu/store} copy-on-write, such that packages added to it |
7320 | during the installation phase are written to the target disk on @file{/mnt} | |
7321 | rather than kept in memory. This is necessary because the first phase of | |
7322 | the @command{guix system init} command (see below) entails downloads or | |
7323 | builds to @file{/gnu/store} which, initially, is an in-memory file system. | |
5af6de3e | 7324 | |
dedb8d5e | 7325 | Next, you have to edit a file and |
5af6de3e | 7326 | provide the declaration of the operating system to be installed. To |
a8cb87ab LC |
7327 | that end, the installation system comes with three text editors: GNU nano |
7328 | (@pxref{Top,,, nano, GNU nano Manual}), GNU Zile (an Emacs clone), and | |
7329 | nvi (a clone of the original BSD @command{vi} editor). | |
efa77c6c LC |
7330 | We strongly recommend storing that file on the target root file system, say, |
7331 | as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your | |
7332 | configuration file once you have rebooted into the newly-installed system. | |
5af6de3e | 7333 | |
dedb8d5e LC |
7334 | @xref{Using the Configuration System}, for an overview of the |
7335 | configuration file. The example configurations discussed in that | |
7336 | section are available under @file{/etc/configuration} in the | |
7337 | installation image. Thus, to get started with a system configuration | |
7338 | providing a graphical display server (a ``desktop'' system), you can run | |
7339 | something along these lines: | |
7340 | ||
7341 | @example | |
7342 | # mkdir /mnt/etc | |
7343 | # cp /etc/configuration/desktop.scm /mnt/etc/config.scm | |
7344 | # zile /mnt/etc/config.scm | |
7345 | @end example | |
7346 | ||
7347 | You should pay attention to what your configuration file contains, and | |
7348 | in particular: | |
7349 | ||
7350 | @itemize | |
7351 | @item | |
7352 | Make sure the @code{grub-configuration} form refers to the device you | |
7353 | want to install GRUB on. | |
7354 | ||
7355 | @item | |
7356 | Be sure that your partition labels match the value of their respective | |
7357 | @code{device} fields in your @code{file-system} configuration, assuming | |
7358 | your @code{file-system} configuration sets the value of @code{title} to | |
7359 | @code{'label}. | |
13fb1bd9 LC |
7360 | |
7361 | @item | |
7362 | If there are encrypted or RAID partitions, make sure to add a | |
7363 | @code{mapped-devices} field to describe them (@pxref{Mapped Devices}). | |
dedb8d5e | 7364 | @end itemize |
5af6de3e | 7365 | |
dd51caac LC |
7366 | Once you are done preparing the configuration file, the new system must |
7367 | be initialized (remember that the target root file system is mounted | |
7368 | under @file{/mnt}): | |
5af6de3e LC |
7369 | |
7370 | @example | |
7371 | guix system init /mnt/etc/config.scm /mnt | |
7372 | @end example | |
7373 | ||
7374 | @noindent | |
dedb8d5e | 7375 | This copies all the necessary files and installs GRUB on |
5af6de3e | 7376 | @file{/dev/sdX}, unless you pass the @option{--no-grub} option. For |
6621cdb6 | 7377 | more information, @pxref{Invoking guix system}. This command may trigger |
5af6de3e LC |
7378 | downloads or builds of missing packages, which can take some time. |
7379 | ||
1bd4e6db LC |
7380 | Once that command has completed---and hopefully succeeded!---you can run |
7381 | @command{reboot} and boot into the new system. The @code{root} password | |
7382 | in the new system is initially empty; other users' passwords need to be | |
7383 | initialized by running the @command{passwd} command as @code{root}, | |
7384 | unless your configuration specifies otherwise | |
7385 | (@pxref{user-account-password, user account passwords}). | |
7386 | ||
7fcf2a0b LC |
7387 | @cindex upgrading GuixSD |
7388 | From then on, you can update GuixSD whenever you want by running | |
7389 | @command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and | |
7390 | then running @command{guix system reconfigure} to build a new system | |
7391 | generation with the latest packages and services (@pxref{Invoking guix | |
7392 | system}). We recommend doing that regularly so that your system | |
7393 | includes the latest security updates (@pxref{Security Updates}). | |
7394 | ||
1bd4e6db | 7395 | Join us on @code{#guix} on the Freenode IRC network or on |
5af6de3e LC |
7396 | @file{guix-devel@@gnu.org} to share your experience---good or not so |
7397 | good. | |
7398 | ||
c8b54374 VL |
7399 | @node Installing GuixSD in a VM |
7400 | @subsection Installing GuixSD in a Virtual Machine | |
7401 | ||
7402 | @cindex virtual machine, GuixSD installation | |
7403 | If you'd like to install GuixSD in a virtual machine (VM) rather than on | |
7404 | your beloved machine, this section is for you. | |
7405 | ||
7406 | To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a | |
7407 | disk image, follow these steps: | |
7408 | ||
7409 | @enumerate | |
7410 | @item | |
a0885414 LF |
7411 | First, retrieve and decompress the GuixSD installation image as |
7412 | described previously (@pxref{USB Stick Installation}). | |
c8b54374 VL |
7413 | |
7414 | @item | |
7415 | Create a disk image that will hold the installed system. To make a | |
7416 | qcow2-formatted disk image, use the @command{qemu-img} command: | |
7417 | ||
7418 | @example | |
7419 | qemu-img create -f qcow2 guixsd.img 5G | |
7420 | @end example | |
7421 | ||
7422 | This will create a 5GB file. | |
7423 | ||
7424 | @item | |
7425 | Boot the USB installation image in an VM: | |
7426 | ||
7427 | @example | |
7428 | qemu-system-x86_64 -m 1024 -smp 1 \ | |
d36b8457 | 7429 | -net user -net nic,model=virtio -boot menu=on \ |
c8b54374 VL |
7430 | -drive file=guixsd.img \ |
7431 | -drive file=guixsd-usb-install-@value{VERSION}.@var{system} | |
7432 | @end example | |
7433 | ||
7434 | In the VM console, quickly press the @kbd{F12} key to enter the boot | |
7435 | menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your | |
7436 | selection. | |
7437 | ||
7438 | @item | |
7439 | You're now root in the VM, proceed with the installation process. | |
7440 | @xref{Preparing for Installation}, and follow the instructions. | |
7441 | @end enumerate | |
7442 | ||
7443 | Once installation is complete, you can boot the system that's on your | |
7444 | @file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do | |
7445 | that. | |
7446 | ||
dedb8d5e | 7447 | @node Building the Installation Image |
5af6de3e LC |
7448 | @subsection Building the Installation Image |
7449 | ||
e32171ee | 7450 | @cindex installation image |
5af6de3e LC |
7451 | The installation image described above was built using the @command{guix |
7452 | system} command, specifically: | |
7453 | ||
622b2304 | 7454 | @c FIXME: 1G is too much; see <http://bugs.gnu.org/23077>. |
5af6de3e | 7455 | @example |
622b2304 | 7456 | guix system disk-image --image-size=1G gnu/system/install.scm |
5af6de3e LC |
7457 | @end example |
7458 | ||
6e6a0401 AE |
7459 | Have a look at @file{gnu/system/install.scm} in the source tree, |
7460 | and see also @ref{Invoking guix system} for more information | |
5af6de3e LC |
7461 | about the installation image. |
7462 | ||
cf4a9129 LC |
7463 | @node System Configuration |
7464 | @section System Configuration | |
b208a005 | 7465 | |
cf4a9129 | 7466 | @cindex system configuration |
3ca2731c | 7467 | The Guix System Distribution supports a consistent whole-system configuration |
cf4a9129 LC |
7468 | mechanism. By that we mean that all aspects of the global system |
7469 | configuration---such as the available system services, timezone and | |
7470 | locale settings, user accounts---are declared in a single place. Such | |
7471 | a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected. | |
91ef73d4 | 7472 | |
cf4a9129 LC |
7473 | One of the advantages of putting all the system configuration under the |
7474 | control of Guix is that it supports transactional system upgrades, and | |
1068f26b | 7475 | makes it possible to roll back to a previous system instantiation, |
cf4a9129 | 7476 | should something go wrong with the new one (@pxref{Features}). Another |
1068f26b | 7477 | advantage is that it makes it easy to replicate the exact same configuration |
cf4a9129 LC |
7478 | across different machines, or at different points in time, without |
7479 | having to resort to additional administration tools layered on top of | |
1068f26b | 7480 | the own tools of the system. |
cf4a9129 | 7481 | @c Yes, we're talking of Puppet, Chef, & co. here. ↑ |
91ef73d4 | 7482 | |
cf4a9129 LC |
7483 | This section describes this mechanism. First we focus on the system |
7484 | administrator's viewpoint---explaining how the system is configured and | |
7485 | instantiated. Then we show how this mechanism can be extended, for | |
7486 | instance to support new system services. | |
91ef73d4 | 7487 | |
cf4a9129 LC |
7488 | @menu |
7489 | * Using the Configuration System:: Customizing your GNU system. | |
7313a52e | 7490 | * operating-system Reference:: Detail of operating-system declarations. |
cf4a9129 | 7491 | * File Systems:: Configuring file system mounts. |
510f9d86 | 7492 | * Mapped Devices:: Block device extra processing. |
cf4a9129 | 7493 | * User Accounts:: Specifying user accounts. |
598e19dc | 7494 | * Locales:: Language and cultural convention settings. |
cf4a9129 | 7495 | * Services:: Specifying system services. |
0ae8c15a | 7496 | * Setuid Programs:: Programs running with root privileges. |
efb5e833 | 7497 | * X.509 Certificates:: Authenticating HTTPS servers. |
996ed739 | 7498 | * Name Service Switch:: Configuring libc's name service switch. |
fd1b1fa2 | 7499 | * Initial RAM Disk:: Linux-Libre bootstrapping. |
88faf933 | 7500 | * GRUB Configuration:: Configuring the boot loader. |
cf4a9129 | 7501 | * Invoking guix system:: Instantiating a system configuration. |
97d76250 | 7502 | * Running GuixSD in a VM:: How to run GuixSD in a virtual machine. |
cf4a9129 LC |
7503 | * Defining Services:: Adding new service definitions. |
7504 | @end menu | |
91ef73d4 | 7505 | |
cf4a9129 LC |
7506 | @node Using the Configuration System |
7507 | @subsection Using the Configuration System | |
64d76fa6 | 7508 | |
cf4a9129 LC |
7509 | The operating system is configured by providing an |
7510 | @code{operating-system} declaration in a file that can then be passed to | |
7511 | the @command{guix system} command (@pxref{Invoking guix system}). A | |
7512 | simple setup, with the default system services, the default Linux-Libre | |
7513 | kernel, initial RAM disk, and boot loader looks like this: | |
91ef73d4 | 7514 | |
cf4a9129 LC |
7515 | @findex operating-system |
7516 | @lisp | |
dd51caac | 7517 | @include os-config-bare-bones.texi |
cf4a9129 | 7518 | @end lisp |
401c53c4 | 7519 | |
cf4a9129 LC |
7520 | This example should be self-describing. Some of the fields defined |
7521 | above, such as @code{host-name} and @code{bootloader}, are mandatory. | |
7522 | Others, such as @code{packages} and @code{services}, can be omitted, in | |
7523 | which case they get a default value. | |
e7f34eb0 | 7524 | |
5d94ac51 LC |
7525 | Below we discuss the effect of some of the most important fields |
7526 | (@pxref{operating-system Reference}, for details about all the available | |
7527 | fields), and how to @dfn{instantiate} the operating system using | |
7528 | @command{guix system}. | |
7529 | ||
7530 | @unnumberedsubsubsec Globally-Visible Packages | |
7531 | ||
cf4a9129 | 7532 | @vindex %base-packages |
5d94ac51 LC |
7533 | The @code{packages} field lists packages that will be globally visible |
7534 | on the system, for all user accounts---i.e., in every user's @code{PATH} | |
7535 | environment variable---in addition to the per-user profiles | |
7536 | (@pxref{Invoking guix package}). The @var{%base-packages} variable | |
7537 | provides all the tools one would expect for basic user and administrator | |
7538 | tasks---including the GNU Core Utilities, the GNU Networking Utilities, | |
7539 | the GNU Zile lightweight text editor, @command{find}, @command{grep}, | |
7540 | etc. The example above adds tcpdump to those, taken from the @code{(gnu | |
7541 | packages admin)} module (@pxref{Package Modules}). | |
e7f34eb0 | 7542 | |
f6c9fb1b LC |
7543 | @findex specification->package |
7544 | Referring to packages by variable name, like @var{tcpdump} above, has | |
7545 | the advantage of being unambiguous; it also allows typos and such to be | |
7546 | diagnosed right away as ``unbound variables''. The downside is that one | |
7547 | needs to know which module defines which package, and to augment the | |
7548 | @code{use-package-modules} line accordingly. To avoid that, one can use | |
7549 | the @code{specification->package} procedure of the @code{(gnu packages)} | |
7550 | module, which returns the best package for a given name or name and | |
7551 | version: | |
7552 | ||
7553 | @lisp | |
7554 | (use-modules (gnu packages)) | |
7555 | ||
7556 | (operating-system | |
7557 | ;; ... | |
7558 | (packages (append (map specification->package | |
d5e59248 | 7559 | '("tcpdump" "htop" "gnupg@@2.0")) |
f6c9fb1b LC |
7560 | %base-packages))) |
7561 | @end lisp | |
7562 | ||
5d94ac51 LC |
7563 | @unnumberedsubsubsec System Services |
7564 | ||
e32171ee | 7565 | @cindex services |
cf4a9129 LC |
7566 | @vindex %base-services |
7567 | The @code{services} field lists @dfn{system services} to be made | |
7568 | available when the system starts (@pxref{Services}). | |
7569 | The @code{operating-system} declaration above specifies that, in | |
7570 | addition to the basic services, we want the @command{lshd} secure shell | |
cd6f6c22 LC |
7571 | daemon listening on port 2222 (@pxref{Networking Services, |
7572 | @code{lsh-service}}). Under the hood, | |
cf4a9129 LC |
7573 | @code{lsh-service} arranges so that @code{lshd} is started with the |
7574 | right command-line options, possibly with supporting configuration files | |
cd6f6c22 LC |
7575 | generated as needed (@pxref{Defining Services}). |
7576 | ||
7577 | @cindex customization, of services | |
7578 | @findex modify-services | |
7579 | Occasionally, instead of using the base services as is, you will want to | |
4d343a14 CM |
7580 | customize them. To do this, use @code{modify-services} (@pxref{Service |
7581 | Reference, @code{modify-services}}) to modify the list. | |
7582 | ||
7583 | For example, suppose you want to modify @code{guix-daemon} and Mingetty | |
7584 | (the console log-in) in the @var{%base-services} list (@pxref{Base | |
7585 | Services, @code{%base-services}}). To do that, you can write the | |
7586 | following in your operating system declaration: | |
cd6f6c22 LC |
7587 | |
7588 | @lisp | |
4d343a14 CM |
7589 | (define %my-services |
7590 | ;; My very own list of services. | |
7591 | (modify-services %base-services | |
7592 | (guix-service-type config => | |
7593 | (guix-configuration | |
7594 | (inherit config) | |
7595 | (use-substitutes? #f) | |
7596 | (extra-options '("--gc-keep-derivations")))) | |
7597 | (mingetty-service-type config => | |
7598 | (mingetty-configuration | |
317d3b47 | 7599 | (inherit config))))) |
4d343a14 CM |
7600 | |
7601 | (operating-system | |
7602 | ;; @dots{} | |
7603 | (services %my-services)) | |
cd6f6c22 LC |
7604 | @end lisp |
7605 | ||
4d343a14 CM |
7606 | This changes the configuration---i.e., the service parameters---of the |
7607 | @code{guix-service-type} instance, and that of all the | |
7608 | @code{mingetty-service-type} instances in the @var{%base-services} list. | |
7609 | Observe how this is accomplished: first, we arrange for the original | |
7610 | configuration to be bound to the identifier @code{config} in the | |
7611 | @var{body}, and then we write the @var{body} so that it evaluates to the | |
7612 | desired configuration. In particular, notice how we use @code{inherit} | |
7613 | to create a new configuration which has the same values as the old | |
7614 | configuration, but with a few modifications. | |
a1ba8475 | 7615 | |
13fb1bd9 LC |
7616 | @cindex encrypted disk |
7617 | The configuration for a typical ``desktop'' usage, with an encrypted | |
7618 | root partition, the X11 display | |
d038b674 LC |
7619 | server, GNOME and Xfce (users can choose which of these desktop |
7620 | environments to use at the log-in screen by pressing @kbd{F1}), network | |
7621 | management, power management, and more, would look like this: | |
dd51caac LC |
7622 | |
7623 | @lisp | |
7624 | @include os-config-desktop.texi | |
7625 | @end lisp | |
7626 | ||
d038b674 LC |
7627 | A graphical environment with a choice of lightweight window managers |
7628 | instead of full-blown desktop environments would look like this: | |
7629 | ||
7630 | @lisp | |
7631 | @include os-config-lightweight-desktop.texi | |
7632 | @end lisp | |
7633 | ||
dd51caac | 7634 | @xref{Desktop Services}, for the exact list of services provided by |
efb5e833 LC |
7635 | @var{%desktop-services}. @xref{X.509 Certificates}, for background |
7636 | information about the @code{nss-certs} package that is used here. | |
dd51caac | 7637 | |
5d94ac51 LC |
7638 | Again, @var{%desktop-services} is just a list of service objects. If |
7639 | you want to remove services from there, you can do so using the | |
7640 | procedures for list filtering (@pxref{SRFI-1 Filtering and | |
7641 | Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the | |
7642 | following expression returns a list that contains all the services in | |
7643 | @var{%desktop-services} minus the Avahi service: | |
7644 | ||
7645 | @example | |
7646 | (remove (lambda (service) | |
7647 | (eq? (service-kind service) avahi-service-type)) | |
7648 | %desktop-services) | |
7649 | @end example | |
7650 | ||
7651 | @unnumberedsubsubsec Instantiating the System | |
7652 | ||
7653 | Assuming the @code{operating-system} declaration | |
7654 | is stored in the @file{my-system-config.scm} | |
cf4a9129 LC |
7655 | file, the @command{guix system reconfigure my-system-config.scm} command |
7656 | instantiates that configuration, and makes it the default GRUB boot | |
65797bff LC |
7657 | entry (@pxref{Invoking guix system}). |
7658 | ||
1068f26b | 7659 | The normal way to change the system configuration is by updating this |
65797bff | 7660 | file and re-running @command{guix system reconfigure}. One should never |
8b499030 | 7661 | have to touch files in @file{/etc} or to run commands that modify the |
65797bff LC |
7662 | system state such as @command{useradd} or @command{grub-install}. In |
7663 | fact, you must avoid that since that would not only void your warranty | |
7664 | but also prevent you from rolling back to previous versions of your | |
7665 | system, should you ever need to. | |
7666 | ||
7667 | @cindex roll-back, of the operating system | |
7668 | Speaking of roll-back, each time you run @command{guix system | |
7669 | reconfigure}, a new @dfn{generation} of the system is created---without | |
7670 | modifying or deleting previous generations. Old system generations get | |
7671 | an entry in the GRUB boot menu, allowing you to boot them in case | |
7672 | something went wrong with the latest generation. Reassuring, no? The | |
7673 | @command{guix system list-generations} command lists the system | |
067a2e2d CM |
7674 | generations available on disk. It is also possible to roll back the |
7675 | system via the commands @command{guix system roll-back} and | |
7676 | @command{guix system switch-generation}. | |
7677 | ||
7678 | Although the command @command{guix system reconfigure} will not modify | |
7679 | previous generations, must take care when the current generation is not | |
7680 | the latest (e.g., after invoking @command{guix system roll-back}), since | |
7681 | the operation might overwrite a later generation (@pxref{Invoking guix | |
7682 | system}). | |
b81e1947 | 7683 | |
5d94ac51 LC |
7684 | @unnumberedsubsubsec The Programming Interface |
7685 | ||
cf4a9129 LC |
7686 | At the Scheme level, the bulk of an @code{operating-system} declaration |
7687 | is instantiated with the following monadic procedure (@pxref{The Store | |
7688 | Monad}): | |
b81e1947 | 7689 | |
cf4a9129 LC |
7690 | @deffn {Monadic Procedure} operating-system-derivation os |
7691 | Return a derivation that builds @var{os}, an @code{operating-system} | |
7692 | object (@pxref{Derivations}). | |
b81e1947 | 7693 | |
cf4a9129 LC |
7694 | The output of the derivation is a single directory that refers to all |
7695 | the packages, configuration files, and other supporting files needed to | |
7696 | instantiate @var{os}. | |
7697 | @end deffn | |
b81e1947 | 7698 | |
5d94ac51 LC |
7699 | This procedure is provided by the @code{(gnu system)} module. Along |
7700 | with @code{(gnu services)} (@pxref{Services}), this module contains the | |
7701 | guts of GuixSD. Make sure to visit it! | |
7702 | ||
7703 | ||
7313a52e LC |
7704 | @node operating-system Reference |
7705 | @subsection @code{operating-system} Reference | |
7706 | ||
7707 | This section summarizes all the options available in | |
7708 | @code{operating-system} declarations (@pxref{Using the Configuration | |
7709 | System}). | |
7710 | ||
7711 | @deftp {Data Type} operating-system | |
7712 | This is the data type representing an operating system configuration. | |
7713 | By that, we mean all the global system configuration, not per-user | |
7714 | configuration (@pxref{Using the Configuration System}). | |
7715 | ||
7716 | @table @asis | |
7717 | @item @code{kernel} (default: @var{linux-libre}) | |
fbb25e56 | 7718 | The package object of the operating system kernel to use@footnote{Currently |
7313a52e LC |
7719 | only the Linux-libre kernel is supported. In the future, it will be |
7720 | possible to use the GNU@tie{}Hurd.}. | |
7721 | ||
ee2a6304 LC |
7722 | @item @code{kernel-arguments} (default: @code{'()}) |
7723 | List of strings or gexps representing additional arguments to pass on | |
1068f26b | 7724 | the command-line of the kernel---e.g., @code{("console=ttyS0")}. |
ee2a6304 | 7725 | |
7313a52e | 7726 | @item @code{bootloader} |
88faf933 | 7727 | The system bootloader configuration object. @xref{GRUB Configuration}. |
7313a52e LC |
7728 | |
7729 | @item @code{initrd} (default: @code{base-initrd}) | |
e32171ee JD |
7730 | @cindex initrd |
7731 | @cindex initial RAM disk | |
7313a52e LC |
7732 | A two-argument monadic procedure that returns an initial RAM disk for |
7733 | the Linux kernel. @xref{Initial RAM Disk}. | |
7734 | ||
f34c56be LC |
7735 | @item @code{firmware} (default: @var{%base-firmware}) |
7736 | @cindex firmware | |
7737 | List of firmware packages loadable by the operating system kernel. | |
7738 | ||
52db41af EB |
7739 | The default includes firmware needed for Atheros- and Broadcom-based |
7740 | WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open}, | |
7741 | respectively). @xref{Hardware Considerations}, for more info on | |
7742 | supported hardware. | |
f34c56be | 7743 | |
7313a52e LC |
7744 | @item @code{host-name} |
7745 | The host name. | |
7746 | ||
7747 | @item @code{hosts-file} | |
7748 | @cindex hosts file | |
24e02c28 | 7749 | A file-like object (@pxref{G-Expressions, file-like objects}) for use as |
7313a52e | 7750 | @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library |
24e02c28 | 7751 | Reference Manual}). The default is a file with entries for |
7313a52e LC |
7752 | @code{localhost} and @var{host-name}. |
7753 | ||
7754 | @item @code{mapped-devices} (default: @code{'()}) | |
7755 | A list of mapped devices. @xref{Mapped Devices}. | |
7756 | ||
7757 | @item @code{file-systems} | |
7758 | A list of file systems. @xref{File Systems}. | |
7759 | ||
7760 | @item @code{swap-devices} (default: @code{'()}) | |
7761 | @cindex swap devices | |
a4ca4362 CM |
7762 | A list of strings identifying devices or files to be used for ``swap |
7763 | space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference | |
7764 | Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}. | |
7765 | It is possible to specify a swap file in a file system on a mapped | |
7766 | device, provided that the necessary device mapping and file system are | |
7767 | also specified. @xref{Mapped Devices} and @ref{File Systems}. | |
7313a52e | 7768 | |
bf87f38a | 7769 | @item @code{users} (default: @code{%base-user-accounts}) |
7313a52e LC |
7770 | @itemx @code{groups} (default: @var{%base-groups}) |
7771 | List of user accounts and groups. @xref{User Accounts}. | |
7772 | ||
7773 | @item @code{skeletons} (default: @code{(default-skeletons)}) | |
e9dffec1 LC |
7774 | A list target file name/file-like object tuples (@pxref{G-Expressions, |
7775 | file-like objects}). These are the skeleton files that will be added to | |
7776 | the home directory of newly-created user accounts. | |
7313a52e LC |
7777 | |
7778 | For instance, a valid value may look like this: | |
7779 | ||
7780 | @example | |
e9dffec1 LC |
7781 | `((".bashrc" ,(plain-file "bashrc" "echo Hello\n")) |
7782 | (".guile" ,(plain-file "guile" | |
7783 | "(use-modules (ice-9 readline)) | |
7784 | (activate-readline)"))) | |
7313a52e LC |
7785 | @end example |
7786 | ||
7787 | @item @code{issue} (default: @var{%default-issue}) | |
7788 | A string denoting the contents of the @file{/etc/issue} file, which is | |
1068f26b | 7789 | displayed when users log in on a text console. |
7313a52e LC |
7790 | |
7791 | @item @code{packages} (default: @var{%base-packages}) | |
7792 | The set of packages installed in the global profile, which is accessible | |
7793 | at @file{/run/current-system/profile}. | |
7794 | ||
1068f26b | 7795 | The default set includes core utilities and it is good practice to |
7313a52e LC |
7796 | install non-core utilities in user profiles (@pxref{Invoking guix |
7797 | package}). | |
7798 | ||
7799 | @item @code{timezone} | |
7800 | A timezone identifying string---e.g., @code{"Europe/Paris"}. | |
7801 | ||
17c20385 LC |
7802 | You can run the @command{tzselect} command to find out which timezone |
7803 | string corresponds to your region. Choosing an invalid timezone name | |
7804 | causes @command{guix system} to fail. | |
7805 | ||
598e19dc LC |
7806 | @item @code{locale} (default: @code{"en_US.utf8"}) |
7807 | The name of the default locale (@pxref{Locale Names,,, libc, The GNU C | |
7808 | Library Reference Manual}). @xref{Locales}, for more information. | |
7809 | ||
7810 | @item @code{locale-definitions} (default: @var{%default-locale-definitions}) | |
7811 | The list of locale definitions to be compiled and that may be used at | |
7812 | run time. @xref{Locales}. | |
7313a52e | 7813 | |
34760ae7 LC |
7814 | @item @code{locale-libcs} (default: @code{(list @var{glibc})}) |
7815 | The list of GNU@tie{}libc packages whose locale data and tools are used | |
7816 | to build the locale definitions. @xref{Locales}, for compatibility | |
7817 | considerations that justify this option. | |
7818 | ||
996ed739 | 7819 | @item @code{name-service-switch} (default: @var{%default-nss}) |
1068f26b | 7820 | Configuration of the libc name service switch (NSS)---a |
996ed739 LC |
7821 | @code{<name-service-switch>} object. @xref{Name Service Switch}, for |
7822 | details. | |
7823 | ||
7313a52e | 7824 | @item @code{services} (default: @var{%base-services}) |
28d939af | 7825 | A list of service objects denoting system services. @xref{Services}. |
7313a52e LC |
7826 | |
7827 | @item @code{pam-services} (default: @code{(base-pam-services)}) | |
7828 | @cindex PAM | |
7829 | @cindex pluggable authentication modules | |
7830 | Linux @dfn{pluggable authentication module} (PAM) services. | |
7831 | @c FIXME: Add xref to PAM services section. | |
7832 | ||
7833 | @item @code{setuid-programs} (default: @var{%setuid-programs}) | |
7834 | List of string-valued G-expressions denoting setuid programs. | |
7835 | @xref{Setuid Programs}. | |
7836 | ||
f5a9ffa0 AK |
7837 | @item @code{sudoers-file} (default: @var{%sudoers-specification}) |
7838 | @cindex sudoers file | |
84765839 LC |
7839 | The contents of the @file{/etc/sudoers} file as a file-like object |
7840 | (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}). | |
7313a52e LC |
7841 | |
7842 | This file specifies which users can use the @command{sudo} command, what | |
7843 | they are allowed to do, and what privileges they may gain. The default | |
7844 | is that only @code{root} and members of the @code{wheel} group may use | |
7845 | @code{sudo}. | |
7846 | ||
7847 | @end table | |
7848 | @end deftp | |
7849 | ||
cf4a9129 LC |
7850 | @node File Systems |
7851 | @subsection File Systems | |
b81e1947 | 7852 | |
cf4a9129 | 7853 | The list of file systems to be mounted is specified in the |
1068f26b | 7854 | @code{file-systems} field of the operating system declaration |
cf4a9129 LC |
7855 | (@pxref{Using the Configuration System}). Each file system is declared |
7856 | using the @code{file-system} form, like this: | |
b81e1947 LC |
7857 | |
7858 | @example | |
cf4a9129 LC |
7859 | (file-system |
7860 | (mount-point "/home") | |
7861 | (device "/dev/sda3") | |
7862 | (type "ext4")) | |
b81e1947 LC |
7863 | @end example |
7864 | ||
cf4a9129 LC |
7865 | As usual, some of the fields are mandatory---those shown in the example |
7866 | above---while others can be omitted. These are described below. | |
b81e1947 | 7867 | |
cf4a9129 LC |
7868 | @deftp {Data Type} file-system |
7869 | Objects of this type represent file systems to be mounted. They | |
7870 | contain the following members: | |
5ff3c4b8 | 7871 | |
cf4a9129 LC |
7872 | @table @asis |
7873 | @item @code{type} | |
7874 | This is a string specifying the type of the file system---e.g., | |
7875 | @code{"ext4"}. | |
5ff3c4b8 | 7876 | |
cf4a9129 LC |
7877 | @item @code{mount-point} |
7878 | This designates the place where the file system is to be mounted. | |
b81e1947 | 7879 | |
cf4a9129 LC |
7880 | @item @code{device} |
7881 | This names the ``source'' of the file system. By default it is the name | |
7882 | of a node under @file{/dev}, but its meaning depends on the @code{title} | |
7883 | field described below. | |
401c53c4 | 7884 | |
cf4a9129 LC |
7885 | @item @code{title} (default: @code{'device}) |
7886 | This is a symbol that specifies how the @code{device} field is to be | |
7887 | interpreted. | |
401c53c4 | 7888 | |
cf4a9129 LC |
7889 | When it is the symbol @code{device}, then the @code{device} field is |
7890 | interpreted as a file name; when it is @code{label}, then @code{device} | |
7891 | is interpreted as a partition label name; when it is @code{uuid}, | |
7892 | @code{device} is interpreted as a partition unique identifier (UUID). | |
da7cabd4 | 7893 | |
661a1d79 | 7894 | UUIDs may be converted from their string representation (as shown by the |
0767f6a6 LC |
7895 | @command{tune2fs -l} command) using the @code{uuid} form@footnote{The |
7896 | @code{uuid} form expects 16-byte UUIDs as defined in | |
7897 | @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the | |
7898 | form of UUID used by the ext2 family of file systems and others, but it | |
7899 | is different from ``UUIDs'' found in FAT file systems, for instance.}, | |
7900 | like this: | |
661a1d79 LC |
7901 | |
7902 | @example | |
7903 | (file-system | |
7904 | (mount-point "/home") | |
7905 | (type "ext4") | |
7906 | (title 'uuid) | |
7907 | (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))) | |
7908 | @end example | |
7909 | ||
cf4a9129 | 7910 | The @code{label} and @code{uuid} options offer a way to refer to disk |
661a1d79 LC |
7911 | partitions without having to hard-code their actual device |
7912 | name@footnote{Note that, while it is tempting to use | |
7913 | @file{/dev/disk/by-uuid} and similar device names to achieve the same | |
7914 | result, this is not recommended: These special device nodes are created | |
7915 | by the udev daemon and may be unavailable at the time the device is | |
7916 | mounted.}. | |
da7cabd4 | 7917 | |
1068f26b | 7918 | However, when the source of a file system is a mapped device (@pxref{Mapped |
5f86a66e LC |
7919 | Devices}), its @code{device} field @emph{must} refer to the mapped |
7920 | device name---e.g., @file{/dev/mapper/root-partition}---and consequently | |
7921 | @code{title} must be set to @code{'device}. This is required so that | |
7922 | the system knows that mounting the file system depends on having the | |
7923 | corresponding device mapping established. | |
7924 | ||
cf4a9129 LC |
7925 | @item @code{flags} (default: @code{'()}) |
7926 | This is a list of symbols denoting mount flags. Recognized flags | |
2c071ce9 LC |
7927 | include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow |
7928 | access to special files), @code{no-suid} (ignore setuid and setgid | |
7929 | bits), and @code{no-exec} (disallow program execution.) | |
da7cabd4 | 7930 | |
cf4a9129 LC |
7931 | @item @code{options} (default: @code{#f}) |
7932 | This is either @code{#f}, or a string denoting mount options. | |
da7cabd4 | 7933 | |
be21979d LC |
7934 | @item @code{mount?} (default: @code{#t}) |
7935 | This value indicates whether to automatically mount the file system when | |
7936 | the system is brought up. When set to @code{#f}, the file system gets | |
7937 | an entry in @file{/etc/fstab} (read by the @command{mount} command) but | |
7938 | is not automatically mounted. | |
7939 | ||
cf4a9129 LC |
7940 | @item @code{needed-for-boot?} (default: @code{#f}) |
7941 | This Boolean value indicates whether the file system is needed when | |
7942 | booting. If that is true, then the file system is mounted when the | |
7943 | initial RAM disk (initrd) is loaded. This is always the case, for | |
7944 | instance, for the root file system. | |
da7cabd4 | 7945 | |
cf4a9129 LC |
7946 | @item @code{check?} (default: @code{#t}) |
7947 | This Boolean indicates whether the file system needs to be checked for | |
7948 | errors before being mounted. | |
f9cc8971 | 7949 | |
4e469051 LC |
7950 | @item @code{create-mount-point?} (default: @code{#f}) |
7951 | When true, the mount point is created if it does not exist yet. | |
7952 | ||
e51710d1 | 7953 | @item @code{dependencies} (default: @code{'()}) |
13fb1bd9 LC |
7954 | This is a list of @code{<file-system>} or @code{<mapped-device>} objects |
7955 | representing file systems that must be mounted or mapped devices that | |
7956 | must be opened before (and unmounted or closed after) this one. | |
e51710d1 LC |
7957 | |
7958 | As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is | |
7959 | a dependency of @file{/sys/fs/cgroup/cpu} and | |
7960 | @file{/sys/fs/cgroup/memory}. | |
7961 | ||
13fb1bd9 LC |
7962 | Another example is a file system that depends on a mapped device, for |
7963 | example for an encrypted partition (@pxref{Mapped Devices}). | |
cf4a9129 LC |
7964 | @end table |
7965 | @end deftp | |
da7cabd4 | 7966 | |
a69576ea LC |
7967 | The @code{(gnu system file-systems)} exports the following useful |
7968 | variables. | |
7969 | ||
7970 | @defvr {Scheme Variable} %base-file-systems | |
7971 | These are essential file systems that are required on normal systems, | |
cc0e575a | 7972 | such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see |
3392ce5d LC |
7973 | below.) Operating system declarations should always contain at least |
7974 | these. | |
a69576ea LC |
7975 | @end defvr |
7976 | ||
7f239fd3 LC |
7977 | @defvr {Scheme Variable} %pseudo-terminal-file-system |
7978 | This is the file system to be mounted as @file{/dev/pts}. It supports | |
7979 | @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar | |
7980 | functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference | |
7981 | Manual}). Pseudo-terminals are used by terminal emulators such as | |
7982 | @command{xterm}. | |
7983 | @end defvr | |
7984 | ||
db17ae5c LC |
7985 | @defvr {Scheme Variable} %shared-memory-file-system |
7986 | This file system is mounted as @file{/dev/shm} and is used to support | |
7987 | memory sharing across processes (@pxref{Memory-mapped I/O, | |
7988 | @code{shm_open},, libc, The GNU C Library Reference Manual}). | |
7989 | @end defvr | |
7990 | ||
3392ce5d LC |
7991 | @defvr {Scheme Variable} %immutable-store |
7992 | This file system performs a read-only ``bind mount'' of | |
7993 | @file{/gnu/store}, making it read-only for all the users including | |
7994 | @code{root}. This prevents against accidental modification by software | |
7995 | running as @code{root} or by system administrators. | |
7996 | ||
7997 | The daemon itself is still able to write to the store: it remounts it | |
7998 | read-write in its own ``name space.'' | |
7999 | @end defvr | |
8000 | ||
a69576ea LC |
8001 | @defvr {Scheme Variable} %binary-format-file-system |
8002 | The @code{binfmt_misc} file system, which allows handling of arbitrary | |
8003 | executable file types to be delegated to user space. This requires the | |
8004 | @code{binfmt.ko} kernel module to be loaded. | |
8005 | @end defvr | |
8006 | ||
8007 | @defvr {Scheme Variable} %fuse-control-file-system | |
8008 | The @code{fusectl} file system, which allows unprivileged users to mount | |
8009 | and unmount user-space FUSE file systems. This requires the | |
8010 | @code{fuse.ko} kernel module to be loaded. | |
8011 | @end defvr | |
8012 | ||
510f9d86 LC |
8013 | @node Mapped Devices |
8014 | @subsection Mapped Devices | |
8015 | ||
8016 | @cindex device mapping | |
8017 | @cindex mapped devices | |
8018 | The Linux kernel has a notion of @dfn{device mapping}: a block device, | |
8019 | such as a hard disk partition, can be @dfn{mapped} into another device, | |
97c8aef1 | 8020 | usually in @code{/dev/mapper/}, |
510f9d86 LC |
8021 | with additional processing over the data that flows through |
8022 | it@footnote{Note that the GNU@tie{}Hurd makes no difference between the | |
8023 | concept of a ``mapped device'' and that of a file system: both boil down | |
8024 | to @emph{translating} input/output operations made on a file to | |
8025 | operations on its backing store. Thus, the Hurd implements mapped | |
8026 | devices, like file systems, using the generic @dfn{translator} mechanism | |
8027 | (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A | |
8028 | typical example is encryption device mapping: all writes to the mapped | |
8029 | device are encrypted, and all reads are deciphered, transparently. | |
97c8aef1 AE |
8030 | Guix extends this notion by considering any device or set of devices that |
8031 | are @dfn{transformed} in some way to create a new device; for instance, | |
8032 | RAID devices are obtained by @dfn{assembling} several other devices, such | |
8033 | as hard disks or partitions, into a new one that behaves as one partition. | |
8034 | Other examples, not yet implemented, are LVM logical volumes. | |
510f9d86 | 8035 | |
97c8aef1 AE |
8036 | Mapped devices are declared using the @code{mapped-device} form, |
8037 | defined as follows; for examples, see below. | |
510f9d86 LC |
8038 | |
8039 | @deftp {Data Type} mapped-device | |
8040 | Objects of this type represent device mappings that will be made when | |
8041 | the system boots up. | |
8042 | ||
9cb426b8 LC |
8043 | @table @code |
8044 | @item source | |
97c8aef1 AE |
8045 | This is either a string specifying the name of the block device to be mapped, |
8046 | such as @code{"/dev/sda3"}, or a list of such strings when several devices | |
8047 | need to be assembled for creating a new one. | |
510f9d86 | 8048 | |
9cb426b8 | 8049 | @item target |
97c8aef1 AE |
8050 | This string specifies the name of the resulting mapped device. For |
8051 | kernel mappers such as encrypted devices of type @code{luks-device-mapping}, | |
8052 | specifying @code{"my-partition"} leads to the creation of | |
510f9d86 | 8053 | the @code{"/dev/mapper/my-partition"} device. |
97c8aef1 AE |
8054 | For RAID devices of type @code{raid-device-mapping}, the full device name |
8055 | such as @code{"/dev/md0"} needs to be given. | |
510f9d86 | 8056 | |
9cb426b8 | 8057 | @item type |
510f9d86 LC |
8058 | This must be a @code{mapped-device-kind} object, which specifies how |
8059 | @var{source} is mapped to @var{target}. | |
8060 | @end table | |
8061 | @end deftp | |
8062 | ||
8063 | @defvr {Scheme Variable} luks-device-mapping | |
8064 | This defines LUKS block device encryption using the @command{cryptsetup} | |
1068f26b | 8065 | command from the package with the same name. It relies on the |
510f9d86 LC |
8066 | @code{dm-crypt} Linux kernel module. |
8067 | @end defvr | |
8068 | ||
97c8aef1 AE |
8069 | @defvr {Scheme Variable} raid-device-mapping |
8070 | This defines a RAID device, which is assembled using the @code{mdadm} | |
8071 | command from the package with the same name. It requires a Linux kernel | |
8072 | module for the appropriate RAID level to be loaded, such as @code{raid456} | |
8073 | for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10. | |
8074 | @end defvr | |
8075 | ||
8076 | @cindex disk encryption | |
8077 | @cindex LUKS | |
8078 | The following example specifies a mapping from @file{/dev/sda3} to | |
8079 | @file{/dev/mapper/home} using LUKS---the | |
ddf1cd51 | 8080 | @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a |
97c8aef1 AE |
8081 | standard mechanism for disk encryption. |
8082 | The @file{/dev/mapper/home} | |
8083 | device can then be used as the @code{device} of a @code{file-system} | |
8084 | declaration (@pxref{File Systems}). | |
8085 | ||
8086 | @example | |
8087 | (mapped-device | |
8088 | (source "/dev/sda3") | |
8089 | (target "home") | |
8090 | (type luks-device-mapping)) | |
8091 | @end example | |
8092 | ||
8093 | Alternatively, to become independent of device numbering, one may obtain | |
8094 | the LUKS UUID (@dfn{unique identifier}) of the source device by a | |
8095 | command like: | |
8096 | ||
8097 | @example | |
8098 | cryptsetup luksUUID /dev/sda3 | |
8099 | @end example | |
8100 | ||
8101 | and use it as follows: | |
8102 | ||
8103 | @example | |
8104 | (mapped-device | |
8105 | (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44")) | |
8106 | (target "home") | |
8107 | (type luks-device-mapping)) | |
8108 | @end example | |
8109 | ||
a4ca4362 CM |
8110 | @cindex swap encryption |
8111 | It is also desirable to encrypt swap space, since swap space may contain | |
8112 | sensitive data. One way to accomplish that is to use a swap file in a | |
8113 | file system on a device mapped via LUKS encryption. In this way, the | |
8114 | swap file is encrypted because the entire device is encrypted. | |
8115 | @xref{Preparing for Installation,,Disk Partitioning}, for an example. | |
8116 | ||
97c8aef1 AE |
8117 | A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1} |
8118 | may be declared as follows: | |
8119 | ||
8120 | @example | |
8121 | (mapped-device | |
8122 | (source (list "/dev/sda1" "/dev/sdb1")) | |
8123 | (target "/dev/md0") | |
8124 | (type raid-device-mapping)) | |
8125 | @end example | |
8126 | ||
8127 | The @file{/dev/md0} device can then be used as the @code{device} of a | |
8128 | @code{file-system} declaration (@pxref{File Systems}). | |
8129 | Note that the RAID level need not be given; it is chosen during the | |
8130 | initial creation and formatting of the RAID device and is determined | |
8131 | automatically later. | |
8132 | ||
8133 | ||
cf4a9129 LC |
8134 | @node User Accounts |
8135 | @subsection User Accounts | |
ee85f3db | 8136 | |
e32171ee JD |
8137 | @cindex users |
8138 | @cindex accounts | |
8139 | @cindex user accounts | |
9bea87a5 LC |
8140 | User accounts and groups are entirely managed through the |
8141 | @code{operating-system} declaration. They are specified with the | |
8142 | @code{user-account} and @code{user-group} forms: | |
ee85f3db | 8143 | |
cf4a9129 LC |
8144 | @example |
8145 | (user-account | |
8146 | (name "alice") | |
8147 | (group "users") | |
24e752c0 LC |
8148 | (supplementary-groups '("wheel" ;allow use of sudo, etc. |
8149 | "audio" ;sound card | |
8150 | "video" ;video devices such as webcams | |
8151 | "cdrom")) ;the good ol' CD-ROM | |
cf4a9129 LC |
8152 | (comment "Bob's sister") |
8153 | (home-directory "/home/alice")) | |
8154 | @end example | |
25083588 | 8155 | |
9bea87a5 LC |
8156 | When booting or upon completion of @command{guix system reconfigure}, |
8157 | the system ensures that only the user accounts and groups specified in | |
8158 | the @code{operating-system} declaration exist, and with the specified | |
8159 | properties. Thus, account or group creations or modifications made by | |
8160 | directly invoking commands such as @command{useradd} are lost upon | |
8161 | reconfiguration or reboot. This ensures that the system remains exactly | |
8162 | as declared. | |
8163 | ||
cf4a9129 LC |
8164 | @deftp {Data Type} user-account |
8165 | Objects of this type represent user accounts. The following members may | |
8166 | be specified: | |
ee85f3db | 8167 | |
cf4a9129 LC |
8168 | @table @asis |
8169 | @item @code{name} | |
8170 | The name of the user account. | |
ee85f3db | 8171 | |
cf4a9129 | 8172 | @item @code{group} |
e32171ee | 8173 | @cindex groups |
cf4a9129 LC |
8174 | This is the name (a string) or identifier (a number) of the user group |
8175 | this account belongs to. | |
ee85f3db | 8176 | |
cf4a9129 LC |
8177 | @item @code{supplementary-groups} (default: @code{'()}) |
8178 | Optionally, this can be defined as a list of group names that this | |
8179 | account belongs to. | |
ee85f3db | 8180 | |
cf4a9129 LC |
8181 | @item @code{uid} (default: @code{#f}) |
8182 | This is the user ID for this account (a number), or @code{#f}. In the | |
8183 | latter case, a number is automatically chosen by the system when the | |
8184 | account is created. | |
ee85f3db | 8185 | |
cf4a9129 | 8186 | @item @code{comment} (default: @code{""}) |
1068f26b | 8187 | A comment about the account, such as the account owner's full name. |
c8c871d1 | 8188 | |
cf4a9129 LC |
8189 | @item @code{home-directory} |
8190 | This is the name of the home directory for the account. | |
ee85f3db | 8191 | |
eb56ee02 LC |
8192 | @item @code{create-home-directory?} (default: @code{#t}) |
8193 | Indicates whether the home directory of this account should be created | |
8194 | if it does not exist yet. | |
8195 | ||
cf4a9129 LC |
8196 | @item @code{shell} (default: Bash) |
8197 | This is a G-expression denoting the file name of a program to be used as | |
8198 | the shell (@pxref{G-Expressions}). | |
ee85f3db | 8199 | |
cf4a9129 LC |
8200 | @item @code{system?} (default: @code{#f}) |
8201 | This Boolean value indicates whether the account is a ``system'' | |
8202 | account. System accounts are sometimes treated specially; for instance, | |
8203 | graphical login managers do not list them. | |
ee85f3db | 8204 | |
1bd4e6db | 8205 | @anchor{user-account-password} |
cf4a9129 | 8206 | @item @code{password} (default: @code{#f}) |
eb59595c LC |
8207 | You would normally leave this field to @code{#f}, initialize user |
8208 | passwords as @code{root} with the @command{passwd} command, and then let | |
9bea87a5 LC |
8209 | users change it with @command{passwd}. Passwords set with |
8210 | @command{passwd} are of course preserved across reboot and | |
8211 | reconfiguration. | |
eb59595c LC |
8212 | |
8213 | If you @emph{do} want to have a preset password for an account, then | |
8214 | this field must contain the encrypted password, as a string. | |
5d1f1177 LC |
8215 | @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information |
8216 | on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference | |
eb59595c | 8217 | Manual}, for information on Guile's @code{crypt} procedure. |
c8c871d1 | 8218 | |
cf4a9129 LC |
8219 | @end table |
8220 | @end deftp | |
ee85f3db | 8221 | |
e32171ee | 8222 | @cindex groups |
cf4a9129 | 8223 | User group declarations are even simpler: |
ee85f3db | 8224 | |
cf4a9129 LC |
8225 | @example |
8226 | (user-group (name "students")) | |
8227 | @end example | |
ee85f3db | 8228 | |
cf4a9129 LC |
8229 | @deftp {Data Type} user-group |
8230 | This type is for, well, user groups. There are just a few fields: | |
af8a56b8 | 8231 | |
cf4a9129 LC |
8232 | @table @asis |
8233 | @item @code{name} | |
1068f26b | 8234 | The name of the group. |
ee85f3db | 8235 | |
cf4a9129 LC |
8236 | @item @code{id} (default: @code{#f}) |
8237 | The group identifier (a number). If @code{#f}, a new number is | |
8238 | automatically allocated when the group is created. | |
ee85f3db | 8239 | |
c8fa3426 LC |
8240 | @item @code{system?} (default: @code{#f}) |
8241 | This Boolean value indicates whether the group is a ``system'' group. | |
8242 | System groups have low numerical IDs. | |
8243 | ||
cf4a9129 LC |
8244 | @item @code{password} (default: @code{#f}) |
8245 | What, user groups can have a password? Well, apparently yes. Unless | |
1068f26b | 8246 | @code{#f}, this field specifies the password of the group. |
ee85f3db | 8247 | |
cf4a9129 LC |
8248 | @end table |
8249 | @end deftp | |
401c53c4 | 8250 | |
cf4a9129 LC |
8251 | For convenience, a variable lists all the basic user groups one may |
8252 | expect: | |
401c53c4 | 8253 | |
cf4a9129 LC |
8254 | @defvr {Scheme Variable} %base-groups |
8255 | This is the list of basic user groups that users and/or packages expect | |
8256 | to be present on the system. This includes groups such as ``root'', | |
8257 | ``wheel'', and ``users'', as well as groups used to control access to | |
8258 | specific devices such as ``audio'', ``disk'', and ``cdrom''. | |
8259 | @end defvr | |
401c53c4 | 8260 | |
bf87f38a LC |
8261 | @defvr {Scheme Variable} %base-user-accounts |
8262 | This is the list of basic system accounts that programs may expect to | |
8263 | find on a GNU/Linux system, such as the ``nobody'' account. | |
8264 | ||
8265 | Note that the ``root'' account is not included here. It is a | |
8266 | special-case and is automatically added whether or not it is specified. | |
8267 | @end defvr | |
8268 | ||
598e19dc LC |
8269 | @node Locales |
8270 | @subsection Locales | |
8271 | ||
8272 | @cindex locale | |
8273 | A @dfn{locale} defines cultural conventions for a particular language | |
8274 | and region of the world (@pxref{Locales,,, libc, The GNU C Library | |
8275 | Reference Manual}). Each locale has a name that typically has the form | |
b2636518 | 8276 | @code{@var{language}_@var{territory}.@var{codeset}}---e.g., |
598e19dc LC |
8277 | @code{fr_LU.utf8} designates the locale for the French language, with |
8278 | cultural conventions from Luxembourg, and using the UTF-8 encoding. | |
8279 | ||
8280 | @cindex locale definition | |
8281 | Usually, you will want to specify the default locale for the machine | |
8282 | using the @code{locale} field of the @code{operating-system} declaration | |
8283 | (@pxref{operating-system Reference, @code{locale}}). | |
8284 | ||
f5582b2c LC |
8285 | The selected locale is automatically added to the @dfn{locale |
8286 | definitions} known to the system if needed, with its codeset inferred | |
8287 | from its name---e.g., @code{bo_CN.utf8} will be assumed to use the | |
8288 | @code{UTF-8} codeset. Additional locale definitions can be specified in | |
8289 | the @code{locale-definitions} slot of @code{operating-system}---this is | |
8290 | useful, for instance, if the codeset could not be inferred from the | |
8291 | locale name. The default set of locale definitions includes some widely | |
8292 | used locales, but not all the available locales, in order to save space. | |
8293 | ||
8294 | For instance, to add the North Frisian locale for Germany, the value of | |
8295 | that field may be: | |
598e19dc LC |
8296 | |
8297 | @example | |
8298 | (cons (locale-definition | |
8299 | (name "fy_DE.utf8") (source "fy_DE")) | |
8300 | %default-locale-definitions) | |
8301 | @end example | |
8302 | ||
8303 | Likewise, to save space, one might want @code{locale-definitions} to | |
8304 | list only the locales that are actually used, as in: | |
8305 | ||
8306 | @example | |
8307 | (list (locale-definition | |
8308 | (name "ja_JP.eucjp") (source "ja_JP") | |
8309 | (charset "EUC-JP"))) | |
8310 | @end example | |
8311 | ||
5c3c1427 LC |
8312 | @vindex LOCPATH |
8313 | The compiled locale definitions are available at | |
46bd6edd LC |
8314 | @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc |
8315 | version, which is the default location where the GNU@tie{}libc provided | |
8316 | by Guix looks for locale data. This can be overridden using the | |
8317 | @code{LOCPATH} environment variable (@pxref{locales-and-locpath, | |
5c3c1427 LC |
8318 | @code{LOCPATH} and locale packages}). |
8319 | ||
598e19dc LC |
8320 | The @code{locale-definition} form is provided by the @code{(gnu system |
8321 | locale)} module. Details are given below. | |
8322 | ||
8323 | @deftp {Data Type} locale-definition | |
8324 | This is the data type of a locale definition. | |
8325 | ||
8326 | @table @asis | |
8327 | ||
8328 | @item @code{name} | |
8329 | The name of the locale. @xref{Locale Names,,, libc, The GNU C Library | |
8330 | Reference Manual}, for more information on locale names. | |
8331 | ||
8332 | @item @code{source} | |
8333 | The name of the source for that locale. This is typically the | |
8334 | @code{@var{language}_@var{territory}} part of the locale name. | |
8335 | ||
8336 | @item @code{charset} (default: @code{"UTF-8"}) | |
8337 | The ``character set'' or ``code set'' for that locale, | |
8338 | @uref{http://www.iana.org/assignments/character-sets, as defined by | |
8339 | IANA}. | |
8340 | ||
8341 | @end table | |
8342 | @end deftp | |
8343 | ||
8344 | @defvr {Scheme Variable} %default-locale-definitions | |
1068f26b | 8345 | A list of commonly used UTF-8 locales, used as the default |
b2636518 | 8346 | value of the @code{locale-definitions} field of @code{operating-system} |
598e19dc | 8347 | declarations. |
b2636518 LC |
8348 | |
8349 | @cindex locale name | |
8350 | @cindex normalized codeset in locale names | |
8351 | These locale definitions use the @dfn{normalized codeset} for the part | |
8352 | that follows the dot in the name (@pxref{Using gettextized software, | |
8353 | normalized codeset,, libc, The GNU C Library Reference Manual}). So for | |
8354 | instance it has @code{uk_UA.utf8} but @emph{not}, say, | |
8355 | @code{uk_UA.UTF-8}. | |
598e19dc | 8356 | @end defvr |
401c53c4 | 8357 | |
34760ae7 LC |
8358 | @subsubsection Locale Data Compatibility Considerations |
8359 | ||
8360 | @cindex incompatibility, of locale data | |
8361 | @code{operating-system} declarations provide a @code{locale-libcs} field | |
8362 | to specify the GNU@tie{}libc packages that are used to compile locale | |
8363 | declarations (@pxref{operating-system Reference}). ``Why would I | |
8364 | care?'', you may ask. Well, it turns out that the binary format of | |
8365 | locale data is occasionally incompatible from one libc version to | |
8366 | another. | |
8367 | ||
8368 | @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html> | |
8369 | @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>. | |
8370 | For instance, a program linked against libc version 2.21 is unable to | |
8371 | read locale data produced with libc 2.22; worse, that program | |
8372 | @emph{aborts} instead of simply ignoring the incompatible locale | |
8373 | data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip | |
8374 | the incompatible locale data, which is already an improvement.}. | |
8375 | Similarly, a program linked against libc 2.22 can read most, but not | |
201fff9e | 8376 | all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE} |
34760ae7 LC |
8377 | data is incompatible); thus calls to @code{setlocale} may fail, but |
8378 | programs will not abort. | |
8379 | ||
8380 | The ``problem'' in GuixSD is that users have a lot of freedom: They can | |
8381 | choose whether and when to upgrade software in their profiles, and might | |
8382 | be using a libc version different from the one the system administrator | |
8383 | used to build the system-wide locale data. | |
8384 | ||
8385 | Fortunately, unprivileged users can also install their own locale data | |
8386 | and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath, | |
8387 | @code{GUIX_LOCPATH} and locale packages}). | |
8388 | ||
8389 | Still, it is best if the system-wide locale data at | |
8390 | @file{/run/current-system/locale} is built for all the libc versions | |
8391 | actually in use on the system, so that all the programs can access | |
8392 | it---this is especially crucial on a multi-user system. To do that, the | |
8393 | administrator can specify several libc packages in the | |
8394 | @code{locale-libcs} field of @code{operating-system}: | |
8395 | ||
8396 | @example | |
8397 | (use-package-modules base) | |
8398 | ||
8399 | (operating-system | |
8400 | ;; @dots{} | |
8401 | (locale-libcs (list glibc-2.21 (canonical-package glibc)))) | |
8402 | @end example | |
8403 | ||
8404 | This example would lead to a system containing locale definitions for | |
8405 | both libc 2.21 and the current version of libc in | |
8406 | @file{/run/current-system/locale}. | |
8407 | ||
8408 | ||
cf4a9129 LC |
8409 | @node Services |
8410 | @subsection Services | |
401c53c4 | 8411 | |
cf4a9129 LC |
8412 | @cindex system services |
8413 | An important part of preparing an @code{operating-system} declaration is | |
8414 | listing @dfn{system services} and their configuration (@pxref{Using the | |
8415 | Configuration System}). System services are typically daemons launched | |
8416 | when the system boots, or other actions needed at that time---e.g., | |
d8b94dbd LC |
8417 | configuring network access. |
8418 | ||
e8b652d4 LC |
8419 | GuixSD has a broad definition of ``service'' (@pxref{Service |
8420 | Composition}), but many services are managed by the GNU@tie{}Shepherd | |
8421 | (@pxref{Shepherd Services}). On a running system, the @command{herd} | |
8422 | command allows you to list the available services, show their status, | |
8423 | start and stop them, or do other specific operations (@pxref{Jump | |
8424 | Start,,, shepherd, The GNU Shepherd Manual}). For example: | |
d8b94dbd LC |
8425 | |
8426 | @example | |
dd17bc38 | 8427 | # herd status |
d8b94dbd LC |
8428 | @end example |
8429 | ||
8430 | The above command, run as @code{root}, lists the currently defined | |
dd17bc38 | 8431 | services. The @command{herd doc} command shows a synopsis of the given |
d8b94dbd LC |
8432 | service: |
8433 | ||
8434 | @example | |
dd17bc38 | 8435 | # herd doc nscd |
d8b94dbd LC |
8436 | Run libc's name service cache daemon (nscd). |
8437 | @end example | |
8438 | ||
8439 | The @command{start}, @command{stop}, and @command{restart} sub-commands | |
8440 | have the effect you would expect. For instance, the commands below stop | |
8441 | the nscd service and restart the Xorg display server: | |
8442 | ||
8443 | @example | |
dd17bc38 | 8444 | # herd stop nscd |
d8b94dbd | 8445 | Service nscd has been stopped. |
dd17bc38 | 8446 | # herd restart xorg-server |
d8b94dbd LC |
8447 | Service xorg-server has been stopped. |
8448 | Service xorg-server has been started. | |
8449 | @end example | |
401c53c4 | 8450 | |
cf4a9129 | 8451 | The following sections document the available services, starting with |
d8b94dbd LC |
8452 | the core services, that may be used in an @code{operating-system} |
8453 | declaration. | |
401c53c4 | 8454 | |
cf4a9129 LC |
8455 | @menu |
8456 | * Base Services:: Essential system services. | |
c311089b | 8457 | * Scheduled Job Execution:: The mcron service. |
92c03a87 | 8458 | * Log Rotation:: The rottlog service. |
cf4a9129 LC |
8459 | * Networking Services:: Network setup, SSH daemon, etc. |
8460 | * X Window:: Graphical display. | |
f2ec23d1 | 8461 | * Printing Services:: Local and remote printer support. |
fe1a39d3 | 8462 | * Desktop Services:: D-Bus and desktop services. |
105369a4 | 8463 | * Database Services:: SQL databases. |
d8c18af8 | 8464 | * Mail Services:: IMAP, POP3, SMTP, and all that. |
78cef99b | 8465 | * Messaging Services:: Messaging services. |
859e367d | 8466 | * Kerberos Services:: Kerberos services. |
58724c48 | 8467 | * Web Services:: Web servers. |
2be1b471 | 8468 | * VPN Services:: VPN daemons. |
eb419bc9 | 8469 | * Network File System:: NFS related services. |
a7cf4eb6 | 8470 | * Continuous Integration:: The Cuirass service. |
bfbf6e1e | 8471 | * Power management Services:: The TLP tool. |
dbc6d370 | 8472 | * Miscellaneous Services:: Other services. |
cf4a9129 | 8473 | @end menu |
401c53c4 | 8474 | |
cf4a9129 LC |
8475 | @node Base Services |
8476 | @subsubsection Base Services | |
a1ba8475 | 8477 | |
cf4a9129 LC |
8478 | The @code{(gnu services base)} module provides definitions for the basic |
8479 | services that one expects from the system. The services exported by | |
8480 | this module are listed below. | |
401c53c4 | 8481 | |
cf4a9129 | 8482 | @defvr {Scheme Variable} %base-services |
31771497 LC |
8483 | This variable contains a list of basic services (@pxref{Service Types |
8484 | and Services}, for more information on service objects) one would | |
cf4a9129 | 8485 | expect from the system: a login service (mingetty) on each tty, syslogd, |
1068f26b | 8486 | the libc name service cache daemon (nscd), the udev device manager, and |
cf4a9129 | 8487 | more. |
401c53c4 | 8488 | |
cf4a9129 LC |
8489 | This is the default value of the @code{services} field of |
8490 | @code{operating-system} declarations. Usually, when customizing a | |
8491 | system, you will want to append services to @var{%base-services}, like | |
8492 | this: | |
401c53c4 | 8493 | |
cf4a9129 | 8494 | @example |
fa1e31b8 | 8495 | (cons* (avahi-service) (lsh-service) %base-services) |
cf4a9129 LC |
8496 | @end example |
8497 | @end defvr | |
401c53c4 | 8498 | |
387e1754 LC |
8499 | @defvr {Scheme Variable} special-files-service-type |
8500 | This is the service that sets up ``special files'' such as | |
8501 | @file{/bin/sh}; an instance of it is part of @code{%base-services}. | |
8502 | ||
8503 | The value associated with @code{special-files-service-type} services | |
8504 | must be a list of tuples where the first element is the ``special file'' | |
8505 | and the second element is its target. By default it is: | |
8506 | ||
8507 | @cindex @file{/bin/sh} | |
8508 | @cindex @file{sh}, in @file{/bin} | |
8509 | @example | |
8510 | `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))) | |
8511 | @end example | |
8512 | ||
8513 | @cindex @file{/usr/bin/env} | |
8514 | @cindex @file{env}, in @file{/usr/bin} | |
8515 | If you want to add, say, @code{/usr/bin/env} to your system, you can | |
8516 | change it to: | |
8517 | ||
8518 | @example | |
8519 | `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")) | |
8520 | ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env"))) | |
8521 | @end example | |
8522 | ||
8523 | Since this is part of @code{%base-services}, you can use | |
8524 | @code{modify-services} to customize the set of special files | |
8525 | (@pxref{Service Reference, @code{modify-services}}). But the simple way | |
8526 | to add a special file is @i{via} the @code{extra-special-file} procedure | |
8527 | (see below.) | |
8528 | @end defvr | |
8529 | ||
8530 | @deffn {Scheme Procedure} extra-special-file @var{file} @var{target} | |
8531 | Use @var{target} as the ``special file'' @var{file}. | |
8532 | ||
8533 | For example, adding the following lines to the @code{services} field of | |
8534 | your operating system declaration leads to a @file{/usr/bin/env} | |
8535 | symlink: | |
8536 | ||
8537 | @example | |
8538 | (extra-special-file "/usr/bin/env" | |
8539 | (file-append coreutils "/bin/env")) | |
8540 | @end example | |
8541 | @end deffn | |
8542 | ||
be1c2c54 | 8543 | @deffn {Scheme Procedure} host-name-service @var{name} |
cf4a9129 LC |
8544 | Return a service that sets the host name to @var{name}. |
8545 | @end deffn | |
401c53c4 | 8546 | |
317d3b47 DC |
8547 | @deffn {Scheme Procedure} login-service @var{config} |
8548 | Return a service to run login according to @var{config}, a | |
8549 | @code{<login-configuration>} object, which specifies the message of the day, | |
8550 | among other things. | |
8551 | @end deffn | |
8552 | ||
8553 | @deftp {Data Type} login-configuration | |
8554 | This is the data type representing the configuration of login. | |
8555 | ||
8556 | @table @asis | |
8557 | ||
8558 | @item @code{motd} | |
e32171ee | 8559 | @cindex message of the day |
317d3b47 DC |
8560 | A file-like object containing the ``message of the day''. |
8561 | ||
8562 | @item @code{allow-empty-passwords?} (default: @code{#t}) | |
8563 | Allow empty passwords by default so that first-time users can log in when | |
8564 | the 'root' account has just been created. | |
8565 | ||
8566 | @end table | |
8567 | @end deftp | |
8568 | ||
66e4f01c LC |
8569 | @deffn {Scheme Procedure} mingetty-service @var{config} |
8570 | Return a service to run mingetty according to @var{config}, a | |
8571 | @code{<mingetty-configuration>} object, which specifies the tty to run, among | |
8572 | other things. | |
cf4a9129 | 8573 | @end deffn |
401c53c4 | 8574 | |
66e4f01c LC |
8575 | @deftp {Data Type} mingetty-configuration |
8576 | This is the data type representing the configuration of Mingetty, which | |
9ee4c9ab | 8577 | provides the default implementation of virtual console log-in. |
66e4f01c LC |
8578 | |
8579 | @table @asis | |
8580 | ||
8581 | @item @code{tty} | |
8582 | The name of the console this Mingetty runs on---e.g., @code{"tty1"}. | |
8583 | ||
66e4f01c LC |
8584 | @item @code{auto-login} (default: @code{#f}) |
8585 | When true, this field must be a string denoting the user name under | |
f9b9a033 | 8586 | which the system automatically logs in. When it is @code{#f}, a |
66e4f01c LC |
8587 | user name and password must be entered to log in. |
8588 | ||
8589 | @item @code{login-program} (default: @code{#f}) | |
8590 | This must be either @code{#f}, in which case the default log-in program | |
8591 | is used (@command{login} from the Shadow tool suite), or a gexp denoting | |
8592 | the name of the log-in program. | |
8593 | ||
8594 | @item @code{login-pause?} (default: @code{#f}) | |
8595 | When set to @code{#t} in conjunction with @var{auto-login}, the user | |
8596 | will have to press a key before the log-in shell is launched. | |
8597 | ||
8598 | @item @code{mingetty} (default: @var{mingetty}) | |
8599 | The Mingetty package to use. | |
8600 | ||
8601 | @end table | |
8602 | @end deftp | |
8603 | ||
9ee4c9ab LF |
8604 | @deffn {Scheme Procedure} agetty-service @var{config} |
8605 | Return a service to run agetty according to @var{config}, an | |
8606 | @code{<agetty-configuration>} object, which specifies the tty to run, | |
8607 | among other things. | |
8608 | @end deffn | |
8609 | ||
8610 | @deftp {Data Type} agetty-configuration | |
8611 | This is the data type representing the configuration of agetty, which | |
8612 | implements virtual and serial console log-in. See the @code{agetty(8)} | |
8613 | man page for more information. | |
8614 | ||
8615 | @table @asis | |
8616 | ||
8617 | @item @code{tty} | |
8618 | The name of the console this agetty runs on, as a string---e.g., | |
8619 | @code{"ttyS0"}. This argument is mandatory. | |
8620 | ||
8621 | @item @code{baud-rate} (default: @code{#f}) | |
8622 | A string containing a comma-separated list of one or more baud rates, in | |
8623 | descending order. | |
8624 | ||
8625 | @item @code{term} (default: @code{#f}) | |
8626 | A string containing the value used for the @code{TERM} environment | |
8627 | variable. | |
8628 | ||
8629 | @item @code{eight-bits?} (default: @code{#f}) | |
8630 | When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is | |
8631 | disabled. | |
8632 | ||
8633 | @item @code{auto-login} (default: @code{#f}) | |
8634 | When passed a login name, as a string, the specified user will be logged | |
8635 | in automatically without prompting for their login name or password. | |
8636 | ||
8637 | @item @code{no-reset?} (default: @code{#f}) | |
8638 | When @code{#t}, don't reset terminal cflags (control modes). | |
8639 | ||
8640 | @item @code{host} (default: @code{#f}) | |
8641 | This accepts a string containing the "login_host", which will be written | |
8642 | into the @file{/var/run/utmpx} file. | |
8643 | ||
8644 | @item @code{remote?} (default: @code{#f}) | |
8645 | When set to @code{#t} in conjunction with @var{host}, this will add an | |
8646 | @code{-r} fakehost option to the command line of the login program | |
8647 | specified in @var{login-program}. | |
8648 | ||
8649 | @item @code{flow-control?} (default: @code{#f}) | |
8650 | When set to @code{#t}, enable hardware (RTS/CTS) flow control. | |
8651 | ||
8652 | @item @code{no-issue?} (default: @code{#f}) | |
8653 | When set to @code{#t}, the contents of the @file{/etc/issue} file will | |
8654 | not be displayed before presenting the login prompt. | |
8655 | ||
8656 | @item @code{init-string} (default: @code{#f}) | |
8657 | This accepts a string that will be sent to the tty or modem before | |
8658 | sending anything else. It can be used to initialize a modem. | |
8659 | ||
8660 | @item @code{no-clear?} (default: @code{#f}) | |
8661 | When set to @code{#t}, agetty will not clear the screen before showing | |
8662 | the login prompt. | |
8663 | ||
8664 | @item @code{login-program} (default: (file-append shadow "/bin/login")) | |
8665 | This must be either a gexp denoting the name of a log-in program, or | |
8666 | unset, in which case the default value is the @command{login} from the | |
8667 | Shadow tool suite. | |
8668 | ||
8669 | @item @code{local-line} (default: @code{#f}) | |
8670 | Control the CLOCAL line flag. This accepts one of three symbols as | |
8671 | arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f}, | |
8672 | the default value chosen by agetty is @code{'auto}. | |
8673 | ||
8674 | @item @code{extract-baud?} (default: @code{#f}) | |
8675 | When set to @code{#t}, instruct agetty to try to extract the baud rate | |
8676 | from the status messages produced by certain types of modems. | |
8677 | ||
8678 | @item @code{skip-login?} (default: @code{#f}) | |
8679 | When set to @code{#t}, do not prompt the user for a login name. This | |
8680 | can be used with @var{login-program} field to use non-standard login | |
8681 | systems. | |
8682 | ||
8683 | @item @code{no-newline?} (default: @code{#f}) | |
8684 | When set to @code{#t}, do not print a newline before printing the | |
8685 | @file{/etc/issue} file. | |
8686 | ||
8687 | @c Is this dangerous only when used with login-program, or always? | |
8688 | @item @code{login-options} (default: @code{#f}) | |
8689 | This option accepts a string containing options that are passed to the | |
8690 | login program. When used with the @var{login-program}, be aware that a | |
8691 | malicious user could try to enter a login name containing embedded | |
8692 | options that could be parsed by the login program. | |
8693 | ||
8694 | @item @code{login-pause} (default: @code{#f}) | |
8695 | When set to @code{#t}, wait for any key before showing the login prompt. | |
8696 | This can be used in conjunction with @var{auto-login} to save memory by | |
8697 | lazily spawning shells. | |
8698 | ||
8699 | @item @code{chroot} (default: @code{#f}) | |
8700 | Change root to the specified directory. This option accepts a directory | |
8701 | path as a string. | |
8702 | ||
8703 | @item @code{hangup?} (default: @code{#f}) | |
8704 | Use the Linux system call @code{vhangup} to do a virtual hangup of the | |
8705 | specified terminal. | |
8706 | ||
8707 | @item @code{keep-baud?} (default: @code{#f}) | |
8708 | When set to @code{#t}, try to keep the existing baud rate. The baud | |
8709 | rates from @var{baud-rate} are used when agetty receives a @key{BREAK} | |
8710 | character. | |
8711 | ||
8712 | @item @code{timeout} (default: @code{#f}) | |
8713 | When set to an integer value, terminate if no user name could be read | |
8714 | within @var{timeout} seconds. | |
8715 | ||
8716 | @item @code{detect-case?} (default: @code{#f}) | |
8717 | When set to @code{#t}, turn on support for detecting an uppercase-only | |
8718 | terminal. This setting will detect a login name containing only | |
8719 | uppercase letters as indicating an uppercase-only terminal and turn on | |
8720 | some upper-to-lower case conversions. Note that this will not support | |
8721 | Unicode characters. | |
8722 | ||
8723 | @item @code{wait-cr?} (default: @code{#f}) | |
8724 | When set to @code{#t}, wait for the user or modem to send a | |
8725 | carriage-return or linefeed character before displaying | |
8726 | @file{/etc/issue} or login prompt. This is typically used with the | |
8727 | @var{init-string} option. | |
8728 | ||
8729 | @item @code{no-hints?} (default: @code{#f}) | |
8730 | When set to @code{#t}, do not print hints about Num, Caps, and Scroll | |
8731 | locks. | |
8732 | ||
8733 | @item @code{no-hostname?} (default: @code{#f}) | |
8734 | By default, the hostname is printed. When this option is set to | |
8735 | @code{#t}, no hostname will be shown at all. | |
8736 | ||
8737 | @item @code{long-hostname?} (default: @code{#f}) | |
8738 | By default, the hostname is only printed until the first dot. When this | |
8739 | option is set to @code{#t}, the fully qualified hostname by | |
8740 | @code{gethostname} or @code{getaddrinfo} is shown. | |
8741 | ||
8742 | @item @code{erase-characters} (default: @code{#f}) | |
8743 | This option accepts a string of additional characters that should be | |
8744 | interpreted as backspace when the user types their login name. | |
8745 | ||
8746 | @item @code{kill-characters} (default: @code{#f}) | |
8747 | This option accepts a string that should be interpreted to mean "ignore | |
8748 | all previous characters" (also called a "kill" character) when the types | |
8749 | their login name. | |
8750 | ||
8751 | @item @code{chdir} (default: @code{#f}) | |
8752 | This option accepts, as a string, a directory path that will be changed | |
8753 | to before login. | |
8754 | ||
8755 | @item @code{delay} (default: @code{#f}) | |
8756 | This options accepts, as an integer, the number of seconds to sleep | |
8757 | before opening the tty and displaying the login prompt. | |
8758 | ||
8759 | @item @code{nice} (default: @code{#f}) | |
8760 | This option accepts, as an integer, the nice value with which to run the | |
8761 | @command{login} program. | |
8762 | ||
8763 | @item @code{extra-options} (default: @code{'()}) | |
8764 | This option provides an "escape hatch" for the user to provide arbitrary | |
8765 | command-line arguments to @command{agetty} as a list of strings. | |
8766 | ||
8767 | @end table | |
8768 | @end deftp | |
8769 | ||
46ec2707 DC |
8770 | @deffn {Scheme Procedure} kmscon-service-type @var{config} |
8771 | Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon} | |
8772 | according to @var{config}, a @code{<kmscon-configuration>} object, which | |
8773 | specifies the tty to run, among other things. | |
8774 | @end deffn | |
8775 | ||
8776 | @deftp {Data Type} kmscon-configuration | |
8777 | This is the data type representing the configuration of Kmscon, which | |
9ee4c9ab | 8778 | implements virtual console log-in. |
46ec2707 DC |
8779 | |
8780 | @table @asis | |
8781 | ||
8782 | @item @code{virtual-terminal} | |
8783 | The name of the console this Kmscon runs on---e.g., @code{"tty1"}. | |
8784 | ||
8785 | @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")}) | |
8786 | A gexp denoting the name of the log-in program. The default log-in program is | |
8787 | @command{login} from the Shadow tool suite. | |
8788 | ||
8789 | @item @code{login-arguments} (default: @code{'("-p")}) | |
8790 | A list of arguments to pass to @command{login}. | |
8791 | ||
8792 | @item @code{hardware-acceleration?} (default: #f) | |
8793 | Whether to use hardware acceleration. | |
8794 | ||
8795 | @item @code{kmscon} (default: @var{kmscon}) | |
8796 | The Kmscon package to use. | |
8797 | ||
8798 | @end table | |
8799 | @end deftp | |
8800 | ||
6454b333 LC |
8801 | @cindex name service cache daemon |
8802 | @cindex nscd | |
be1c2c54 | 8803 | @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @ |
4aee6e60 | 8804 | [#:name-services '()] |
1068f26b | 8805 | Return a service that runs the libc name service cache daemon (nscd) with the |
b893f1ae LC |
8806 | given @var{config}---an @code{<nscd-configuration>} object. @xref{Name |
8807 | Service Switch}, for an example. | |
cf4a9129 | 8808 | @end deffn |
401c53c4 | 8809 | |
6454b333 LC |
8810 | @defvr {Scheme Variable} %nscd-default-configuration |
8811 | This is the default @code{<nscd-configuration>} value (see below) used | |
1068f26b | 8812 | by @code{nscd-service}. It uses the caches defined by |
6454b333 LC |
8813 | @var{%nscd-default-caches}; see below. |
8814 | @end defvr | |
8815 | ||
8816 | @deftp {Data Type} nscd-configuration | |
1068f26b | 8817 | This is the data type representing the name service cache daemon (nscd) |
6454b333 LC |
8818 | configuration. |
8819 | ||
8820 | @table @asis | |
8821 | ||
b893f1ae LC |
8822 | @item @code{name-services} (default: @code{'()}) |
8823 | List of packages denoting @dfn{name services} that must be visible to | |
8824 | the nscd---e.g., @code{(list @var{nss-mdns})}. | |
8825 | ||
8826 | @item @code{glibc} (default: @var{glibc}) | |
8827 | Package object denoting the GNU C Library providing the @command{nscd} | |
8828 | command. | |
8829 | ||
6454b333 | 8830 | @item @code{log-file} (default: @code{"/var/log/nscd.log"}) |
1068f26b | 8831 | Name of the nscd log file. This is where debugging output goes when |
6454b333 LC |
8832 | @code{debug-level} is strictly positive. |
8833 | ||
8834 | @item @code{debug-level} (default: @code{0}) | |
1068f26b | 8835 | Integer denoting the debugging levels. Higher numbers mean that more |
6454b333 LC |
8836 | debugging output is logged. |
8837 | ||
8838 | @item @code{caches} (default: @var{%nscd-default-caches}) | |
8839 | List of @code{<nscd-cache>} objects denoting things to be cached; see | |
8840 | below. | |
8841 | ||
8842 | @end table | |
8843 | @end deftp | |
8844 | ||
8845 | @deftp {Data Type} nscd-cache | |
8846 | Data type representing a cache database of nscd and its parameters. | |
8847 | ||
8848 | @table @asis | |
8849 | ||
8850 | @item @code{database} | |
8851 | This is a symbol representing the name of the database to be cached. | |
8852 | Valid values are @code{passwd}, @code{group}, @code{hosts}, and | |
8853 | @code{services}, which designate the corresponding NSS database | |
8854 | (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}). | |
8855 | ||
8856 | @item @code{positive-time-to-live} | |
8857 | @itemx @code{negative-time-to-live} (default: @code{20}) | |
8858 | A number representing the number of seconds during which a positive or | |
8859 | negative lookup result remains in cache. | |
8860 | ||
8861 | @item @code{check-files?} (default: @code{#t}) | |
8862 | Whether to check for updates of the files corresponding to | |
8863 | @var{database}. | |
8864 | ||
8865 | For instance, when @var{database} is @code{hosts}, setting this flag | |
8866 | instructs nscd to check for updates in @file{/etc/hosts} and to take | |
8867 | them into account. | |
8868 | ||
8869 | @item @code{persistent?} (default: @code{#t}) | |
8870 | Whether the cache should be stored persistently on disk. | |
8871 | ||
8872 | @item @code{shared?} (default: @code{#t}) | |
8873 | Whether the cache should be shared among users. | |
8874 | ||
8875 | @item @code{max-database-size} (default: 32@tie{}MiB) | |
8876 | Maximum size in bytes of the database cache. | |
8877 | ||
8878 | @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert | |
8879 | @c settings, so leave them out. | |
8880 | ||
8881 | @end table | |
8882 | @end deftp | |
8883 | ||
8884 | @defvr {Scheme Variable} %nscd-default-caches | |
8885 | List of @code{<nscd-cache>} objects used by default by | |
1068f26b | 8886 | @code{nscd-configuration} (see above). |
6454b333 LC |
8887 | |
8888 | It enables persistent and aggressive caching of service and host name | |
8889 | lookups. The latter provides better host name lookup performance, | |
8890 | resilience in the face of unreliable name servers, and also better | |
8891 | privacy---often the result of host name lookups is in local cache, so | |
8892 | external name servers do not even need to be queried. | |
8893 | @end defvr | |
8894 | ||
ec2e2f6c | 8895 | @anchor{syslog-configuration-type} |
e32171ee JD |
8896 | @cindex syslog |
8897 | @cindex logging | |
ec2e2f6c DC |
8898 | @deftp {Data Type} syslog-configuration |
8899 | This data type represents the configuration of the syslog daemon. | |
6454b333 | 8900 | |
ec2e2f6c DC |
8901 | @table @asis |
8902 | @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")}) | |
8903 | The syslog daemon to use. | |
8904 | ||
8905 | @item @code{config-file} (default: @code{%default-syslog.conf}) | |
8906 | The syslog configuration file to use. | |
8907 | ||
8908 | @end table | |
8909 | @end deftp | |
8910 | ||
8911 | @anchor{syslog-service} | |
e32171ee | 8912 | @cindex syslog |
ec2e2f6c DC |
8913 | @deffn {Scheme Procedure} syslog-service @var{config} |
8914 | Return a service that runs a syslog daemon according to @var{config}. | |
44abcb28 LC |
8915 | |
8916 | @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more | |
8917 | information on the configuration file syntax. | |
cf4a9129 | 8918 | @end deffn |
401c53c4 | 8919 | |
0adfe95a LC |
8920 | @anchor{guix-configuration-type} |
8921 | @deftp {Data Type} guix-configuration | |
8922 | This data type represents the configuration of the Guix build daemon. | |
8923 | @xref{Invoking guix-daemon}, for more information. | |
8924 | ||
8925 | @table @asis | |
8926 | @item @code{guix} (default: @var{guix}) | |
8927 | The Guix package to use. | |
401c53c4 | 8928 | |
0adfe95a LC |
8929 | @item @code{build-group} (default: @code{"guixbuild"}) |
8930 | Name of the group for build user accounts. | |
401c53c4 | 8931 | |
0adfe95a LC |
8932 | @item @code{build-accounts} (default: @code{10}) |
8933 | Number of build user accounts to create. | |
401c53c4 | 8934 | |
0adfe95a | 8935 | @item @code{authorize-key?} (default: @code{#t}) |
e32171ee | 8936 | @cindex substitutes, authorization thereof |
5b58c28b LC |
8937 | Whether to authorize the substitute keys listed in |
8938 | @code{authorized-keys}---by default that of @code{hydra.gnu.org} | |
0adfe95a LC |
8939 | (@pxref{Substitutes}). |
8940 | ||
5b58c28b LC |
8941 | @vindex %default-authorized-guix-keys |
8942 | @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys}) | |
8943 | The list of authorized key files for archive imports, as a list of | |
8944 | string-valued gexps (@pxref{Invoking guix archive}). By default, it | |
8945 | contains that of @code{hydra.gnu.org} (@pxref{Substitutes}). | |
8946 | ||
0adfe95a LC |
8947 | @item @code{use-substitutes?} (default: @code{#t}) |
8948 | Whether to use substitutes. | |
8949 | ||
b0b9f6e0 LC |
8950 | @item @code{substitute-urls} (default: @var{%default-substitute-urls}) |
8951 | The list of URLs where to look for substitutes by default. | |
8952 | ||
0adfe95a LC |
8953 | @item @code{extra-options} (default: @code{'()}) |
8954 | List of extra command-line options for @command{guix-daemon}. | |
8955 | ||
dc0ef095 LC |
8956 | @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"}) |
8957 | File where @command{guix-daemon}'s standard output and standard error | |
8958 | are written. | |
8959 | ||
0adfe95a | 8960 | @item @code{lsof} (default: @var{lsof}) |
f78903f3 | 8961 | The lsof package to use. |
0adfe95a | 8962 | |
93d32da9 LF |
8963 | @item @code{http-proxy} (default: @code{#f}) |
8964 | The HTTP proxy used for downloading fixed-output derivations and | |
8965 | substitutes. | |
8966 | ||
b191f0a6 LF |
8967 | @item @code{tmpdir} (default: @code{#f}) |
8968 | A directory path where the @command{guix-daemon} will perform builds. | |
8969 | ||
0adfe95a LC |
8970 | @end table |
8971 | @end deftp | |
8972 | ||
8973 | @deffn {Scheme Procedure} guix-service @var{config} | |
8974 | Return a service that runs the Guix build daemon according to | |
8975 | @var{config}. | |
cf4a9129 | 8976 | @end deffn |
a1ba8475 | 8977 | |
be1c2c54 | 8978 | @deffn {Scheme Procedure} udev-service [#:udev udev] |
cf4a9129 LC |
8979 | Run @var{udev}, which populates the @file{/dev} directory dynamically. |
8980 | @end deffn | |
401c53c4 | 8981 | |
a535e122 LF |
8982 | @deffn {Scheme Procedure} urandom-seed-service @var{#f} |
8983 | Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom} | |
8984 | when rebooting. | |
8985 | @end deffn | |
8986 | ||
8987 | @defvr {Scheme Variable} %random-seed-file | |
8988 | This is the name of the file where some random bytes are saved by | |
8989 | @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting. | |
8990 | It defaults to @file{/var/lib/random-seed}. | |
8991 | @end defvr | |
8992 | ||
e32171ee JD |
8993 | @cindex keymap |
8994 | @cindex keyboard | |
b3d05f48 | 8995 | @deffn {Scheme Procedure} console-keymap-service @var{files} ... |
dedb8d5e | 8996 | @cindex keyboard layout |
b3d05f48 AK |
8997 | Return a service to load console keymaps from @var{files} using |
8998 | @command{loadkeys} command. Most likely, you want to load some default | |
8999 | keymap, which can be done like this: | |
9000 | ||
9001 | @example | |
9002 | (console-keymap-service "dvorak") | |
9003 | @end example | |
9004 | ||
9005 | Or, for example, for a Swedish keyboard, you may need to combine | |
9006 | the following keymaps: | |
9007 | @example | |
9008 | (console-keymap-service "se-lat6" "se-fi-lat6") | |
9009 | @end example | |
9010 | ||
9011 | Also you can specify a full file name (or file names) of your keymap(s). | |
9012 | See @code{man loadkeys} for details. | |
9013 | ||
5eca9459 AK |
9014 | @end deffn |
9015 | ||
e32171ee JD |
9016 | @cindex mouse |
9017 | @cindex gpm | |
1aaf116d | 9018 | @deffn {Scheme Procedure} gpm-service [#:gpm @var{gpm}] @ |
8664cc88 LC |
9019 | [#:options] |
9020 | Run @var{gpm}, the general-purpose mouse daemon, with the given | |
9021 | command-line @var{options}. GPM allows users to use the mouse in the console, | |
9022 | notably to select, copy, and paste text. The default value of @var{options} | |
9023 | uses the @code{ps2} protocol, which works for both USB and PS/2 mice. | |
9024 | ||
9025 | This service is not part of @var{%base-services}. | |
9026 | @end deffn | |
9027 | ||
f1e900a3 LC |
9028 | @anchor{guix-publish-service-type} |
9029 | @deffn {Scheme Variable} guix-publish-service-type @var{config} | |
9030 | This is the service type for @command{guix publish} (@pxref{Invoking | |
9031 | guix publish}). @var{config} must be a @code{guix-configuration} | |
9032 | object, as described below. | |
1c52181f LC |
9033 | |
9034 | This assumes that @file{/etc/guix} already contains a signing key pair as | |
9035 | created by @command{guix archive --generate-key} (@pxref{Invoking guix | |
9036 | archive}). If that is not the case, the service will fail to start. | |
9037 | @end deffn | |
9038 | ||
f1e900a3 LC |
9039 | @deftp {Data Type} guix-publish-configuration |
9040 | Data type representing the configuration of the @code{guix publish} | |
9041 | service. | |
9042 | ||
9043 | @table @asis | |
9044 | @item @code{guix} (default: @code{guix}) | |
9045 | The Guix package to use. | |
9046 | ||
9047 | @item @code{port} (default: @code{80}) | |
9048 | The TCP port to listen for connections. | |
9049 | ||
9050 | @item @code{host} (default: @code{"localhost"}) | |
9051 | The host (and thus, network interface) to listen to. Use | |
9052 | @code{"0.0.0.0"} to listen on all the network interfaces. | |
697ddb88 LC |
9053 | |
9054 | @item @code{compression-level} (default: @code{3}) | |
9055 | The gzip compression level at which substitutes are compressed. Use | |
9056 | @code{0} to disable compression altogether, and @code{9} to get the best | |
9057 | compression ratio at the expense of increased CPU usage. | |
9058 | ||
9059 | @item @code{nar-path} (default: @code{"nar"}) | |
9060 | The URL path at which ``nars'' can be fetched. @xref{Invoking guix | |
9061 | publish, @code{--nar-path}}, for details. | |
f1e900a3 LC |
9062 | @end table |
9063 | @end deftp | |
9064 | ||
b58cbf9a DC |
9065 | @anchor{rngd-service} |
9066 | @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @ | |
9067 | [#:device "/dev/hwrng"] | |
9068 | Return a service that runs the @command{rngd} program from @var{rng-tools} | |
9069 | to add @var{device} to the kernel's entropy pool. The service will fail if | |
9070 | @var{device} does not exist. | |
9071 | @end deffn | |
a69576ea | 9072 | |
909147e4 RW |
9073 | @anchor{pam-limits-service} |
9074 | @cindex session limits | |
9075 | @cindex ulimit | |
9076 | @cindex priority | |
9077 | @deffn {Scheme Procedure} pam-limits-service [#:limits @var{limits}] | |
9078 | ||
9079 | Return a service that installs a configuration file for the | |
9080 | @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html, | |
9081 | @code{pam_limits} module}. The procedure optionally takes a list of | |
9082 | @code{pam-limits-entry} values, which can be used to specify | |
9083 | @code{ulimit} limits and nice priority limits to user sessions. | |
9084 | ||
9085 | The following limits definition sets two hard and soft limits for all | |
9086 | login sessions of users in the @code{realtime} group: | |
9087 | ||
9088 | @example | |
9089 | (pam-limits-service | |
9090 | (list | |
9091 | (pam-limits-entry "@@realtime" 'both 'rtprio 99) | |
9092 | (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited))) | |
9093 | @end example | |
9094 | ||
9095 | The first entry increases the maximum realtime priority for | |
9096 | non-privileged processes; the second entry lifts any restriction of the | |
9097 | maximum address space that can be locked in memory. These settings are | |
9098 | commonly used for real-time audio systems. | |
9099 | @end deffn | |
9100 | ||
c311089b LC |
9101 | @node Scheduled Job Execution |
9102 | @subsubsection Scheduled Job Execution | |
9103 | ||
9104 | @cindex cron | |
e32171ee | 9105 | @cindex mcron |
c311089b LC |
9106 | @cindex scheduling jobs |
9107 | The @code{(gnu services mcron)} module provides an interface to | |
9108 | GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,, | |
9109 | mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional | |
9110 | Unix @command{cron} daemon; the main difference is that it is | |
9111 | implemented in Guile Scheme, which provides a lot of flexibility when | |
9112 | specifying the scheduling of jobs and their actions. | |
9113 | ||
8ac6282c | 9114 | The example below defines an operating system that runs the |
c311089b | 9115 | @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files}) |
8ac6282c LC |
9116 | and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as |
9117 | well as the @command{mkid} command on behalf of an unprivileged user | |
9118 | (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses | |
9119 | gexps to introduce job definitions that are passed to mcron | |
9120 | (@pxref{G-Expressions}). | |
c311089b LC |
9121 | |
9122 | @lisp | |
9123 | (use-modules (guix) (gnu) (gnu services mcron)) | |
8ac6282c | 9124 | (use-package-modules base idutils) |
c311089b LC |
9125 | |
9126 | (define updatedb-job | |
8ac6282c LC |
9127 | ;; Run 'updatedb' at 3AM every day. Here we write the |
9128 | ;; job's action as a Scheme procedure. | |
c311089b | 9129 | #~(job '(next-hour '(3)) |
8ac6282c LC |
9130 | (lambda () |
9131 | (execl (string-append #$findutils "/bin/updatedb") | |
9132 | "updatedb" | |
9133 | "--prunepaths=/tmp /var/tmp /gnu/store")))) | |
c311089b LC |
9134 | |
9135 | (define garbage-collector-job | |
9136 | ;; Collect garbage 5 minutes after midnight every day. | |
8ac6282c | 9137 | ;; The job's action is a shell command. |
c311089b LC |
9138 | #~(job "5 0 * * *" ;Vixie cron syntax |
9139 | "guix gc -F 1G")) | |
9140 | ||
80d944b7 | 9141 | (define idutils-job |
8ac6282c LC |
9142 | ;; Update the index database as user "charlie" at 12:15PM |
9143 | ;; and 19:15PM. This runs from the user's home directory. | |
9144 | #~(job '(next-minute-from (next-hour '(12 19)) '(15)) | |
9145 | (string-append #$idutils "/bin/mkid src") | |
9146 | #:user "charlie")) | |
9147 | ||
c311089b LC |
9148 | (operating-system |
9149 | ;; @dots{} | |
9150 | (services (cons (mcron-service (list garbage-collector-job | |
8ac6282c LC |
9151 | updatedb-job |
9152 | idutils-job)) | |
c311089b LC |
9153 | %base-services))) |
9154 | @end lisp | |
9155 | ||
9156 | @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron}, | |
9157 | for more information on mcron job specifications. Below is the | |
9158 | reference of the mcron service. | |
9159 | ||
9160 | @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron2}] | |
9161 | Return an mcron service running @var{mcron} that schedules @var{jobs}, a | |
9162 | list of gexps denoting mcron job specifications. | |
9163 | ||
9164 | This is a shorthand for: | |
9165 | @example | |
80d944b7 LC |
9166 | (service mcron-service-type |
9167 | (mcron-configuration (mcron mcron) (jobs jobs))) | |
c311089b LC |
9168 | @end example |
9169 | @end deffn | |
9170 | ||
9171 | @defvr {Scheme Variable} mcron-service-type | |
9172 | This is the type of the @code{mcron} service, whose value is an | |
9173 | @code{mcron-configuration} object. | |
9174 | ||
9175 | This service type can be the target of a service extension that provides | |
9176 | it additional job specifications (@pxref{Service Composition}). In | |
80d944b7 | 9177 | other words, it is possible to define services that provide additional |
c311089b LC |
9178 | mcron jobs to run. |
9179 | @end defvr | |
9180 | ||
9181 | @deftp {Data Type} mcron-configuration | |
9182 | Data type representing the configuration of mcron. | |
9183 | ||
9184 | @table @asis | |
9185 | @item @code{mcron} (default: @var{mcron2}) | |
9186 | The mcron package to use. | |
9187 | ||
9188 | @item @code{jobs} | |
9189 | This is a list of gexps (@pxref{G-Expressions}), where each gexp | |
9190 | corresponds to an mcron job specification (@pxref{Syntax, mcron job | |
9191 | specifications,, mcron, GNU@tie{}mcron}). | |
9192 | @end table | |
9193 | @end deftp | |
9194 | ||
9195 | ||
92c03a87 JN |
9196 | @node Log Rotation |
9197 | @subsubsection Log Rotation | |
9198 | ||
9199 | @cindex rottlog | |
9200 | @cindex log rotation | |
e32171ee | 9201 | @cindex logging |
92c03a87 JN |
9202 | Log files such as those found in @file{/var/log} tend to grow endlessly, |
9203 | so it's a good idea to @dfn{rotate} them once in a while---i.e., archive | |
9204 | their contents in separate files, possibly compressed. The @code{(gnu | |
9205 | services admin)} module provides an interface to GNU@tie{}Rot[t]log, a | |
9206 | log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}). | |
9207 | ||
9208 | The example below defines an operating system that provides log rotation | |
9209 | with the default settings. | |
9210 | ||
9211 | @lisp | |
9212 | (use-modules (guix) (gnu)) | |
9213 | (use-service-modules admin mcron) | |
9214 | (use-package-modules base idutils) | |
9215 | ||
9216 | (operating-system | |
9217 | ;; @dots{} | |
9218 | (services (cons* (mcron-service) | |
9219 | (service rottlog-service-type (rottlog-configuration)) | |
9220 | %base-services))) | |
9221 | @end lisp | |
9222 | ||
9223 | @defvr {Scheme Variable} rottlog-service-type | |
9224 | This is the type of the Rottlog service, whose value is a | |
9225 | @code{rottlog-configuration} object. | |
9226 | ||
9227 | This service type can define mcron jobs (@pxref{Scheduled Job | |
9228 | Execution}) to run the rottlog service. | |
9229 | @end defvr | |
9230 | ||
9231 | @deftp {Data Type} rottlog-configuration | |
9232 | Data type representing the configuration of rottlog. | |
9233 | ||
9234 | @table @asis | |
9235 | @item @code{rottlog} (default: @code{rottlog}) | |
9236 | The Rottlog package to use. | |
9237 | ||
9238 | @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")}) | |
9239 | The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,, | |
9240 | rottlog, GNU Rot[t]log Manual}). | |
9241 | ||
9fc221b5 | 9242 | @item @code{periodic-rotations} (default: @code{`(("weekly" %default-rotations))}) |
92c03a87 JN |
9243 | A list of Rottlog period-name/period-config tuples. |
9244 | ||
9245 | For example, taking an example from the Rottlog manual (@pxref{Period | |
9246 | Related File Examples,,, rottlog, GNU Rot[t]log Manual}), a valid tuple | |
9247 | might be: | |
9248 | ||
9249 | @example | |
9250 | ("daily" ,(plain-file "daily" | |
9251 | "\ | |
9252 | /var/log/apache/* @{ | |
9253 | storedir apache-archives | |
9254 | rotate 6 | |
9255 | notifempty | |
9256 | nocompress | |
9257 | @}")) | |
9258 | @end example | |
9259 | ||
9260 | @item @code{jobs} | |
9261 | This is a list of gexps where each gexp corresponds to an mcron job | |
9262 | specification (@pxref{Scheduled Job Execution}). | |
9263 | @end table | |
9264 | @end deftp | |
9265 | ||
9266 | @defvr {Scheme Variable} %default-rotations | |
9267 | Specifies weekly rotation of @var{%rotated-files} and | |
9268 | @code{"/var/log/shepherd.log"}. | |
9269 | @end defvr | |
9270 | ||
9271 | @defvr {Scheme Variable} %rotated-files | |
9272 | The list of syslog-controlled files to be rotated. By default it is: | |
9273 | @code{'("/var/log/messages" "/var/log/secure")}. | |
9274 | @end defvr | |
9275 | ||
cf4a9129 LC |
9276 | @node Networking Services |
9277 | @subsubsection Networking Services | |
401c53c4 | 9278 | |
fa1e31b8 | 9279 | The @code{(gnu services networking)} module provides services to configure |
cf4a9129 | 9280 | the network interface. |
a1ba8475 | 9281 | |
a023cca8 | 9282 | @cindex DHCP, networking service |
be1c2c54 | 9283 | @deffn {Scheme Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}] |
a023cca8 LC |
9284 | Return a service that runs @var{dhcp}, a Dynamic Host Configuration |
9285 | Protocol (DHCP) client, on all the non-loopback network interfaces. | |
9286 | @end deffn | |
9287 | ||
8de3e4b3 LC |
9288 | @defvr {Scheme Variable} static-networking-service-type |
9289 | This is the type for statically-configured network interfaces. | |
9290 | @c TODO Document <static-networking> data structures. | |
9291 | @end defvr | |
9292 | ||
be1c2c54 | 9293 | @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @ |
1f9803c2 | 9294 | [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] |
cf4a9129 | 9295 | Return a service that starts @var{interface} with address @var{ip}. If |
1f9803c2 LC |
9296 | @var{netmask} is true, use it as the network mask. If @var{gateway} is true, |
9297 | it must be a string specifying the default network gateway. | |
8de3e4b3 LC |
9298 | |
9299 | This procedure can be called several times, one for each network | |
9300 | interface of interest. Behind the scenes what it does is extend | |
9301 | @code{static-networking-service-type} with additional network interfaces | |
9302 | to handle. | |
cf4a9129 | 9303 | @end deffn |
8b315a6d | 9304 | |
b7d0c494 | 9305 | @cindex wicd |
e32171ee JD |
9306 | @cindex wireless |
9307 | @cindex WiFi | |
87f40011 | 9308 | @cindex network management |
be1c2c54 | 9309 | @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}] |
87f40011 LC |
9310 | Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network |
9311 | management daemon that aims to simplify wired and wireless networking. | |
9312 | ||
9313 | This service adds the @var{wicd} package to the global profile, providing | |
9314 | several commands to interact with the daemon and configure networking: | |
9315 | @command{wicd-client}, a graphical user interface, and the @command{wicd-cli} | |
9316 | and @command{wicd-curses} user interfaces. | |
b7d0c494 MW |
9317 | @end deffn |
9318 | ||
c0a9589d | 9319 | @cindex NetworkManager |
b726096b CB |
9320 | |
9321 | @defvr {Scheme Variable} network-manager-service-type | |
9322 | This is the service type for the | |
9323 | @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager} | |
9324 | service. The value for this service type is a | |
9325 | @code{network-manager-configuration} record. | |
9326 | @end defvr | |
9327 | ||
9328 | @deftp {Data Type} network-manager-configuration | |
9329 | Data type representing the configuration of NetworkManager. | |
9330 | ||
9331 | @table @asis | |
9332 | @item @code{network-manager} (default: @code{network-manager}) | |
9333 | The NetworkManager package to use. | |
9334 | ||
9335 | @item @code{dns} (default: @code{"default"}) | |
9336 | Processing mode for DNS, which affects how NetworkManager uses the | |
9337 | @code{resolv.conf} configuration file. | |
9338 | ||
9339 | @table @samp | |
9340 | @item default | |
9341 | NetworkManager will update @code{resolv.conf} to reflect the nameservers | |
9342 | provided by currently active connections. | |
9343 | ||
9344 | @item dnsmasq | |
9345 | NetworkManager will run @code{dnsmasq} as a local caching nameserver, | |
9346 | using a "split DNS" configuration if you are connected to a VPN, and | |
9347 | then update @code{resolv.conf} to point to the local nameserver. | |
9348 | ||
9349 | @item none | |
9350 | NetworkManager will not modify @code{resolv.conf}. | |
9351 | @end table | |
9352 | ||
9353 | @end table | |
9354 | @end deftp | |
c0a9589d | 9355 | |
76192896 | 9356 | @cindex Connman |
34d60c49 MO |
9357 | @deffn {Scheme Variable} connman-service-type |
9358 | This is the service type to run @url{https://01.org/connman,Connman}, | |
9359 | a network connection manager. | |
9360 | ||
9361 | Its value must be an | |
9362 | @code{connman-configuration} record as in this example: | |
9363 | ||
9364 | @example | |
9365 | (service connman-service-type | |
9366 | (connman-configuration | |
9367 | (disable-vpn? #t))) | |
9368 | @end example | |
9369 | ||
9370 | See below for details about @code{connman-configuration}. | |
76192896 EF |
9371 | @end deffn |
9372 | ||
34d60c49 MO |
9373 | @deftp {Data Type} connman-configuration |
9374 | Data Type representing the configuration of connman. | |
9375 | ||
9376 | @table @asis | |
9377 | @item @code{connman} (default: @var{connman}) | |
9378 | The connman package to use. | |
9379 | ||
9380 | @item @code{disable-vpn?} (default: @code{#f}) | |
9381 | When true, enable connman's vpn plugin. | |
9382 | @end table | |
9383 | @end deftp | |
9384 | ||
2cccbc2a | 9385 | @cindex WPA Supplicant |
cbf1024e LC |
9386 | @defvr {Scheme Variable} wpa-supplicant-service-type |
9387 | This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA | |
2cccbc2a | 9388 | supplicant}, an authentication daemon required to authenticate against |
cbf1024e | 9389 | encrypted WiFi or ethernet networks. It is configured to listen for |
2cccbc2a | 9390 | requests on D-Bus. |
cbf1024e LC |
9391 | |
9392 | The value of this service is the @code{wpa-supplicant} package to use. | |
9393 | Thus, it can be instantiated like this: | |
9394 | ||
9395 | @lisp | |
9396 | (use-modules (gnu services networking) | |
9397 | (gnu packages admin)) | |
9398 | ||
9747d189 | 9399 | (service wpa-supplicant-service-type wpa-supplicant) |
cbf1024e LC |
9400 | @end lisp |
9401 | @end defvr | |
2cccbc2a | 9402 | |
e32171ee JD |
9403 | @cindex NTP |
9404 | @cindex real time clock | |
be1c2c54 | 9405 | @deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @ |
dc0322b5 LC |
9406 | [#:servers @var{%ntp-servers}] @ |
9407 | [#:allow-large-adjustment? #f] | |
63854bcb LC |
9408 | Return a service that runs the daemon from @var{ntp}, the |
9409 | @uref{http://www.ntp.org, Network Time Protocol package}. The daemon will | |
9410 | keep the system clock synchronized with that of @var{servers}. | |
dc0322b5 LC |
9411 | @var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to |
9412 | make an initial adjustment of more than 1,000 seconds. | |
63854bcb LC |
9413 | @end deffn |
9414 | ||
9415 | @defvr {Scheme Variable} %ntp-servers | |
9416 | List of host names used as the default NTP servers. | |
9417 | @end defvr | |
9418 | ||
9260b9d1 TD |
9419 | @cindex inetd |
9420 | @deffn {Scheme variable} inetd-service-type | |
9421 | This service runs the @command{inetd} (@pxref{inetd invocation,,, | |
9422 | inetutils, GNU Inetutils}) daemon. @command{inetd} listens for | |
9423 | connections on internet sockets, and lazily starts the specified server | |
9424 | program when a connection is made on one of these sockets. | |
9425 | ||
9426 | The value of this service is an @code{inetd-configuration} object. The | |
9427 | following example configures the @command{inetd} daemon to provide the | |
9428 | built-in @command{echo} service, as well as an smtp service which | |
9429 | forwards smtp traffic over ssh to a server @code{smtp-server} behind a | |
9430 | gateway @code{hostname}: | |
9431 | ||
9432 | @example | |
9433 | (service | |
9434 | inetd-service-type | |
9435 | (inetd-configuration | |
9436 | (entries (list | |
9437 | (inetd-entry | |
9438 | (name "echo") | |
9439 | (socket-type 'stream) | |
9440 | (protocol "tcp") | |
9441 | (wait? #f) | |
9442 | (user "root")) | |
9443 | (inetd-entry | |
9444 | (node "127.0.0.1") | |
9445 | (name "smtp") | |
9446 | (socket-type 'stream) | |
9447 | (protocol "tcp") | |
9448 | (wait? #f) | |
9449 | (user "root") | |
9450 | (program (file-append openssh "/bin/ssh")) | |
9451 | (arguments | |
9452 | '("ssh" "-qT" "-i" "/path/to/ssh_key" | |
9453 | "-W" "smtp-server:25" "user@@hostname"))))) | |
9454 | @end example | |
9455 | ||
9456 | See below for more details about @code{inetd-configuration}. | |
9457 | @end deffn | |
9458 | ||
9459 | @deftp {Data Type} inetd-configuration | |
9460 | Data type representing the configuration of @command{inetd}. | |
9461 | ||
9462 | @table @asis | |
9463 | @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")}) | |
9464 | The @command{inetd} executable to use. | |
9465 | ||
9466 | @item @code{entries} (default: @code{'()}) | |
9467 | A list of @command{inetd} service entries. Each entry should be created | |
9468 | by the @code{inetd-entry} constructor. | |
9469 | @end table | |
9470 | @end deftp | |
9471 | ||
9472 | @deftp {Data Type} inetd-entry | |
9473 | Data type representing an entry in the @command{inetd} configuration. | |
9474 | Each entry corresponds to a socket where @command{inetd} will listen for | |
9475 | requests. | |
9476 | ||
9477 | @table @asis | |
9478 | @item @code{node} (default: @code{#f}) | |
9479 | Optional string, a comma-separated list of local addresses | |
9480 | @command{inetd} should use when listening for this service. | |
9481 | @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete | |
9482 | description of all options. | |
9483 | @item @code{name} | |
9484 | A string, the name must correspond to an entry in @code{/etc/services}. | |
9485 | @item @code{socket-type} | |
9486 | One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or | |
9487 | @code{'seqpacket}. | |
9488 | @item @code{protocol} | |
9489 | A string, must correspond to an entry in @code{/etc/protocols}. | |
9490 | @item @code{wait?} (default: @code{#t}) | |
9491 | Whether @command{inetd} should wait for the server to exit before | |
9492 | listening to new service requests. | |
9493 | @item @code{user} | |
9494 | A string containing the user (and, optionally, group) name of the user | |
9495 | as whom the server should run. The group name can be specified in a | |
9496 | suffix, separated by a colon or period, i.e. @code{"user"}, | |
9497 | @code{"user:group"} or @code{"user.group"}. | |
9498 | @item @code{program} (default: @code{"internal"}) | |
9499 | The server program which will serve the requests, or @code{"internal"} | |
9500 | if @command{inetd} should use a built-in service. | |
9501 | @item @code{arguments} (default: @code{'()}) | |
9502 | A list strings or file-like objects, which are the server program's | |
9503 | arguments, starting with the zeroth argument, i.e. the name of the | |
9504 | program itself. For @command{inetd}'s internal services, this entry | |
9505 | must be @code{'()} or @code{'("internal")}. | |
9506 | @end table | |
9507 | ||
9508 | @xref{Configuration file,,, inetutils, GNU Inetutils} for a more | |
9509 | detailed discussion of each configuration field. | |
9510 | @end deftp | |
9511 | ||
e32171ee | 9512 | @cindex Tor |
375c6108 LC |
9513 | @deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}] |
9514 | Return a service to run the @uref{https://torproject.org, Tor} anonymous | |
9515 | networking daemon. | |
8b315a6d | 9516 | |
375c6108 | 9517 | The daemon runs as the @code{tor} unprivileged user. It is passed |
6331bde7 LC |
9518 | @var{config-file}, a file-like object, with an additional @code{User tor} line |
9519 | and lines for hidden services added via @code{tor-hidden-service}. Run | |
9520 | @command{man tor} for information about the configuration file. | |
9521 | @end deffn | |
9522 | ||
24a8ef3b | 9523 | @cindex hidden service |
6331bde7 LC |
9524 | @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping} |
9525 | Define a new Tor @dfn{hidden service} called @var{name} and implementing | |
9526 | @var{mapping}. @var{mapping} is a list of port/host tuples, such as: | |
9527 | ||
9528 | @example | |
24a8ef3b LC |
9529 | '((22 "127.0.0.1:22") |
9530 | (80 "127.0.0.1:8080")) | |
6331bde7 LC |
9531 | @end example |
9532 | ||
9533 | In this example, port 22 of the hidden service is mapped to local port 22, and | |
9534 | port 80 is mapped to local port 8080. | |
9535 | ||
6629099a LC |
9536 | This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where |
9537 | the @file{hostname} file contains the @code{.onion} host name for the hidden | |
6331bde7 LC |
9538 | service. |
9539 | ||
9540 | See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor | |
9541 | project's documentation} for more information. | |
cf4a9129 | 9542 | @end deffn |
8b315a6d | 9543 | |
be1c2c54 | 9544 | @deffn {Scheme Procedure} bitlbee-service [#:bitlbee bitlbee] @ |
4627a464 LC |
9545 | [#:interface "127.0.0.1"] [#:port 6667] @ |
9546 | [#:extra-settings ""] | |
9547 | Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that | |
9548 | acts as a gateway between IRC and chat networks. | |
9549 | ||
9550 | The daemon will listen to the interface corresponding to the IP address | |
9551 | specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only | |
9552 | local clients can connect, whereas @code{0.0.0.0} means that connections can | |
9553 | come from any networking interface. | |
9554 | ||
9555 | In addition, @var{extra-settings} specifies a string to append to the | |
9556 | configuration file. | |
9557 | @end deffn | |
9558 | ||
71b0601a | 9559 | Furthermore, @code{(gnu services ssh)} provides the following services. |
e32171ee JD |
9560 | @cindex SSH |
9561 | @cindex SSH server | |
8b315a6d | 9562 | |
be1c2c54 | 9563 | @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @ |
5833bf33 | 9564 | [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @ |
cf4a9129 LC |
9565 | [#:allow-empty-passwords? #f] [#:root-login? #f] @ |
9566 | [#:syslog-output? #t] [#:x11-forwarding? #t] @ | |
9567 | [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @ | |
21cc905a | 9568 | [#:public-key-authentication? #t] [#:initialize? #t] |
cf4a9129 LC |
9569 | Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}. |
9570 | @var{host-key} must designate a file containing the host key, and readable | |
9571 | only by root. | |
72e25e35 | 9572 | |
5833bf33 DP |
9573 | When @var{daemonic?} is true, @command{lshd} will detach from the |
9574 | controlling terminal and log its output to syslogd, unless one sets | |
9575 | @var{syslog-output?} to false. Obviously, it also makes lsh-service | |
9576 | depend on existence of syslogd service. When @var{pid-file?} is true, | |
9577 | @command{lshd} writes its PID to the file called @var{pid-file}. | |
9578 | ||
cf4a9129 LC |
9579 | When @var{initialize?} is true, automatically create the seed and host key |
9580 | upon service activation if they do not exist yet. This may take long and | |
9581 | require interaction. | |
8b315a6d | 9582 | |
20dd519c LC |
9583 | When @var{initialize?} is false, it is up to the user to initialize the |
9584 | randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create | |
9585 | a key pair with the private key stored in file @var{host-key} (@pxref{lshd | |
9586 | basics,,, lsh, LSH Manual}). | |
9587 | ||
cf4a9129 LC |
9588 | When @var{interfaces} is empty, lshd listens for connections on all the |
9589 | network interfaces; otherwise, @var{interfaces} must be a list of host names | |
9590 | or addresses. | |
9bf3c1a7 | 9591 | |
20dd519c LC |
9592 | @var{allow-empty-passwords?} specifies whether to accept log-ins with empty |
9593 | passwords, and @var{root-login?} specifies whether to accept log-ins as | |
cf4a9129 | 9594 | root. |
4af2447e | 9595 | |
cf4a9129 LC |
9596 | The other options should be self-descriptive. |
9597 | @end deffn | |
4af2447e | 9598 | |
e32171ee JD |
9599 | @cindex SSH |
9600 | @cindex SSH server | |
d8f31281 LC |
9601 | @deffn {Scheme Variable} openssh-service-type |
9602 | This is the type for the @uref{http://www.openssh.org, OpenSSH} secure | |
9603 | shell daemon, @command{sshd}. Its value must be an | |
9604 | @code{openssh-configuration} record as in this example: | |
9605 | ||
9606 | @example | |
9607 | (service openssh-service-type | |
9608 | (openssh-configuration | |
9609 | (x11-forwarding? #t) | |
9610 | (permit-root-login 'without-password))) | |
9611 | @end example | |
9612 | ||
9613 | See below for details about @code{openssh-configuration}. | |
86d8f6d3 JL |
9614 | @end deffn |
9615 | ||
d8f31281 LC |
9616 | @deftp {Data Type} openssh-configuration |
9617 | This is the configuration record for OpenSSH's @command{sshd}. | |
9618 | ||
9619 | @table @asis | |
9620 | @item @code{pid-file} (default: @code{"/var/run/sshd.pid"}) | |
9621 | Name of the file where @command{sshd} writes its PID. | |
9622 | ||
9623 | @item @code{port-number} (default: @code{22}) | |
9624 | TCP port on which @command{sshd} listens for incoming connections. | |
9625 | ||
9626 | @item @code{permit-root-login} (default: @code{#f}) | |
9627 | This field determines whether and when to allow logins as root. If | |
9628 | @code{#f}, root logins are disallowed; if @code{#t}, they are allowed. | |
9629 | If it's the symbol @code{'without-password}, then root logins are | |
9630 | permitted but not with password-based authentication. | |
9631 | ||
9632 | @item @code{allow-empty-passwords?} (default: @code{#f}) | |
9633 | When true, users with empty passwords may log in. When false, they may | |
9634 | not. | |
9635 | ||
9636 | @item @code{password-authentication?} (default: @code{#t}) | |
9637 | When true, users may log in with their password. When false, they have | |
9638 | other authentication methods. | |
9639 | ||
9640 | @item @code{public-key-authentication?} (default: @code{#t}) | |
9641 | When true, users may log in using public key authentication. When | |
9642 | false, users have to use other authentication method. | |
9643 | ||
9644 | Authorized public keys are stored in @file{~/.ssh/authorized_keys}. | |
9645 | This is used only by protocol version 2. | |
9646 | ||
d8f31281 LC |
9647 | @item @code{x11-forwarding?} (default: @code{#f}) |
9648 | When true, forwarding of X11 graphical client connections is | |
9649 | enabled---in other words, @command{ssh} options @option{-X} and | |
9650 | @option{-Y} will work. | |
9651 | ||
563c5d42 CL |
9652 | @item @code{challenge-response-authentication?} (default: @code{#f}) |
9653 | Specifies whether challenge response authentication is allowed (e.g. via | |
9654 | PAM). | |
9655 | ||
9656 | @item @code{use-pam?} (default: @code{#t}) | |
9657 | Enables the Pluggable Authentication Module interface. If set to | |
9658 | @code{#t}, this will enable PAM authentication using | |
9659 | @code{challenge-response-authentication?} and | |
9660 | @code{password-authentication?}, in addition to PAM account and session | |
9661 | module processing for all authentication types. | |
9662 | ||
9663 | Because PAM challenge response authentication usually serves an | |
9664 | equivalent role to password authentication, you should disable either | |
9665 | @code{challenge-response-authentication?} or | |
9666 | @code{password-authentication?}. | |
f895dce4 CL |
9667 | |
9668 | @item @code{print-last-log?} (default: @code{#t}) | |
9669 | Specifies whether @command{sshd} should print the date and time of the | |
9670 | last user login when a user logs in interactively. | |
12723370 CL |
9671 | |
9672 | @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))}) | |
9673 | Configures external subsystems (e.g. file transfer daemon). | |
9674 | ||
9675 | This is a list of two-element lists, each of which containing the | |
9676 | subsystem name and a command (with optional arguments) to execute upon | |
9677 | subsystem request. | |
9678 | ||
9679 | The command @command{internal-sftp} implements an in-process SFTP | |
9680 | server. Alternately, one can specify the @command{sftp-server} command: | |
9681 | @example | |
9682 | (service openssh-service-type | |
9683 | (openssh-configuration | |
9684 | (subsystems | |
9685 | '(("sftp" ,(file-append openssh "/libexec/sftp-server")))))) | |
9686 | @end example | |
d8f31281 LC |
9687 | @end table |
9688 | @end deftp | |
9689 | ||
71b0601a DC |
9690 | @deffn {Scheme Procedure} dropbear-service [@var{config}] |
9691 | Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH | |
9692 | daemon} with the given @var{config}, a @code{<dropbear-configuration>} | |
9693 | object. | |
9694 | ||
9695 | For example, to specify a Dropbear service listening on port 1234, add | |
9696 | this call to the operating system's @code{services} field: | |
9697 | ||
9698 | @example | |
9699 | (dropbear-service (dropbear-configuration | |
9700 | (port-number 1234))) | |
9701 | @end example | |
9702 | @end deffn | |
9703 | ||
9704 | @deftp {Data Type} dropbear-configuration | |
9705 | This data type represents the configuration of a Dropbear SSH daemon. | |
9706 | ||
9707 | @table @asis | |
9708 | @item @code{dropbear} (default: @var{dropbear}) | |
9709 | The Dropbear package to use. | |
9710 | ||
9711 | @item @code{port-number} (default: 22) | |
9712 | The TCP port where the daemon waits for incoming connections. | |
9713 | ||
9714 | @item @code{syslog-output?} (default: @code{#t}) | |
9715 | Whether to enable syslog output. | |
9716 | ||
9717 | @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"}) | |
9718 | File name of the daemon's PID file. | |
9719 | ||
9720 | @item @code{root-login?} (default: @code{#f}) | |
9721 | Whether to allow @code{root} logins. | |
9722 | ||
9723 | @item @code{allow-empty-passwords?} (default: @code{#f}) | |
9724 | Whether to allow empty passwords. | |
9725 | ||
9726 | @item @code{password-authentication?} (default: @code{#t}) | |
9727 | Whether to enable password-based authentication. | |
9728 | @end table | |
9729 | @end deftp | |
9730 | ||
fa0c1d61 LC |
9731 | @defvr {Scheme Variable} %facebook-host-aliases |
9732 | This variable contains a string for use in @file{/etc/hosts} | |
9733 | (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each | |
9734 | line contains a entry that maps a known server name of the Facebook | |
9735 | on-line service---e.g., @code{www.facebook.com}---to the local | |
9736 | host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}. | |
9737 | ||
9738 | This variable is typically used in the @code{hosts-file} field of an | |
7313a52e LC |
9739 | @code{operating-system} declaration (@pxref{operating-system Reference, |
9740 | @file{/etc/hosts}}): | |
fa0c1d61 LC |
9741 | |
9742 | @example | |
9743 | (use-modules (gnu) (guix)) | |
9744 | ||
9745 | (operating-system | |
9746 | (host-name "mymachine") | |
9747 | ;; ... | |
9748 | (hosts-file | |
9749 | ;; Create a /etc/hosts file with aliases for "localhost" | |
9750 | ;; and "mymachine", as well as for Facebook servers. | |
24e02c28 LC |
9751 | (plain-file "hosts" |
9752 | (string-append (local-host-aliases host-name) | |
9753 | %facebook-host-aliases)))) | |
fa0c1d61 LC |
9754 | @end example |
9755 | ||
9756 | This mechanism can prevent programs running locally, such as Web | |
9757 | browsers, from accessing Facebook. | |
9758 | @end defvr | |
9759 | ||
965a7332 LC |
9760 | The @code{(gnu services avahi)} provides the following definition. |
9761 | ||
be1c2c54 | 9762 | @deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @ |
965a7332 LC |
9763 | [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @ |
9764 | [#:ipv6? #t] [#:wide-area? #f] @ | |
c8695f32 | 9765 | [#:domains-to-browse '()] [#:debug? #f] |
965a7332 LC |
9766 | Return a service that runs @command{avahi-daemon}, a system-wide |
9767 | mDNS/DNS-SD responder that allows for service discovery and | |
cc9c1f39 LC |
9768 | "zero-configuration" host name lookups (see @uref{http://avahi.org/}), and |
9769 | extends the name service cache daemon (nscd) so that it can resolve | |
9770 | @code{.local} host names using | |
1065bed9 LC |
9771 | @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally, |
9772 | add the @var{avahi} package to the system profile so that commands such as | |
9773 | @command{avahi-browse} are directly usable. | |
965a7332 LC |
9774 | |
9775 | If @var{host-name} is different from @code{#f}, use that as the host name to | |
9776 | publish for this machine; otherwise, use the machine's actual host name. | |
9777 | ||
9778 | When @var{publish?} is true, publishing of host names and services is allowed; | |
9779 | in particular, avahi-daemon will publish the machine's host name and IP | |
9780 | address via mDNS on the local network. | |
9781 | ||
9782 | When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled. | |
9783 | ||
9784 | Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6 | |
9785 | sockets. | |
9786 | @end deffn | |
9787 | ||
c32d02fe SB |
9788 | @deffn {Scheme Variable} openvswitch-service-type |
9789 | This is the type of the @uref{http://www.openvswitch.org, Open vSwitch} | |
9790 | service, whose value should be an @code{openvswitch-configuration} | |
9791 | object. | |
9792 | @end deffn | |
9793 | ||
9794 | @deftp {Data Type} openvswitch-configuration | |
9795 | Data type representing the configuration of Open vSwitch, a multilayer | |
9796 | virtual switch which is designed to enable massive network automation | |
9797 | through programmatic extension. | |
9798 | ||
9799 | @table @asis | |
9800 | @item @code{package} (default: @var{openvswitch}) | |
9801 | Package object of the Open vSwitch. | |
9802 | ||
9803 | @end table | |
9804 | @end deftp | |
965a7332 | 9805 | |
cf4a9129 LC |
9806 | @node X Window |
9807 | @subsubsection X Window | |
68ad877c | 9808 | |
e32171ee JD |
9809 | @cindex X11 |
9810 | @cindex X Window System | |
cf4a9129 LC |
9811 | Support for the X Window graphical display system---specifically |
9812 | Xorg---is provided by the @code{(gnu services xorg)} module. Note that | |
9813 | there is no @code{xorg-service} procedure. Instead, the X server is | |
9814 | started by the @dfn{login manager}, currently SLiM. | |
4af2447e | 9815 | |
935644c0 DC |
9816 | @deftp {Data Type} sddm-configuration |
9817 | This is the data type representing the sddm service configuration. | |
9818 | ||
9819 | @table @asis | |
9820 | @item @code{display-server} (default: "x11") | |
9821 | Select display server to use for the greeter. Valid values are "x11" | |
9822 | or "wayland". | |
9823 | ||
9824 | @item @code{numlock} (default: "on") | |
9825 | Valid values are "on", "off" or "none". | |
9826 | ||
9827 | @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")}) | |
9828 | Command to run when halting. | |
9829 | ||
9830 | @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")}) | |
9831 | Command to run when rebooting. | |
9832 | ||
9833 | @item @code{theme} (default "maldives") | |
9834 | Theme to use. Default themes provided by SDDM are "elarun" or "maldives". | |
9835 | ||
9836 | @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes") | |
9837 | Directory to look for themes. | |
9838 | ||
9839 | @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces") | |
9840 | Directory to look for faces. | |
9841 | ||
9842 | @item @code{default-path} (default "/run/current-system/profile/bin") | |
9843 | Default PATH to use. | |
9844 | ||
9845 | @item @code{minimum-uid} (default 1000) | |
9846 | Minimum UID to display in SDDM. | |
9847 | ||
9848 | @item @code{maximum-uid} (default 2000) | |
9849 | Maximum UID to display in SDDM | |
9850 | ||
9851 | @item @code{remember-last-user?} (default #t) | |
9852 | Remember last user. | |
9853 | ||
9854 | @item @code{remember-last-session?} (default #t) | |
9855 | Remember last session. | |
9856 | ||
9857 | @item @code{hide-users} (default "") | |
9858 | Usernames to hide from SDDM greeter. | |
9859 | ||
9860 | @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")}) | |
9861 | Users with shells listed will be hidden from the SDDM greeter. | |
9862 | ||
9863 | @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")}) | |
9864 | Script to run before starting a wayland session. | |
9865 | ||
9866 | @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions") | |
9867 | Directory to look for desktop files starting wayland sessions. | |
9868 | ||
9869 | @item @code{xorg-server-path} (default @code{xorg-start-command}) | |
9870 | Path to xorg-server. | |
9871 | ||
9872 | @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")}) | |
9873 | Path to xauth. | |
9874 | ||
9875 | @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")}) | |
9876 | Path to Xephyr. | |
9877 | ||
9878 | @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")}) | |
9879 | Script to run after starting xorg-server. | |
9880 | ||
9881 | @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")}) | |
9882 | Script to run before stopping xorg-server. | |
9883 | ||
9884 | @item @code{xsession-command} (default: @code{xinitr }) | |
9885 | Script to run before starting a X session. | |
9886 | ||
9887 | @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions") | |
9888 | Directory to look for desktop files starting X sessions. | |
9889 | ||
9890 | @item @code{minimum-vt} (default: 7) | |
9891 | Minimum VT to use. | |
9892 | ||
9893 | @item @code{xserver-arguments} (default "-nolisten tcp") | |
9894 | Arguments to pass to xorg-server. | |
9895 | ||
9896 | @item @code{auto-login-user} (default "") | |
9897 | User to use for auto-login. | |
9898 | ||
9899 | @item @code{auto-login-session} (default "") | |
9900 | Desktop file to use for auto-login. | |
9901 | ||
9902 | @item @code{relogin?} (default #f) | |
9903 | Relogin after logout. | |
9904 | ||
9905 | @end table | |
9906 | @end deftp | |
9907 | ||
e32171ee | 9908 | @cindex login manager |
935644c0 DC |
9909 | @deffn {Scheme Procedure} sddm-service config |
9910 | Return a service that spawns the SDDM graphical login manager for config of | |
9911 | type @code{<sddm-configuration>}. | |
9912 | ||
9913 | @example | |
9914 | (sddm-service (sddm-configuration | |
9915 | (auto-login-user "Alice") | |
9916 | (auto-login-session "xfce.desktop"))) | |
9917 | @end example | |
9918 | @end deffn | |
9919 | ||
be1c2c54 | 9920 | @deffn {Scheme Procedure} slim-service [#:allow-empty-passwords? #f] @ |
0ecc3bf3 LC |
9921 | [#:auto-login? #f] [#:default-user ""] [#:startx] @ |
9922 | [#:theme @var{%default-slim-theme}] @ | |
4bd43bbe | 9923 | [#:theme-name @var{%default-slim-theme-name}] |
cf4a9129 LC |
9924 | Return a service that spawns the SLiM graphical login manager, which in |
9925 | turn starts the X display server with @var{startx}, a command as returned by | |
9926 | @code{xorg-start-command}. | |
4af2447e | 9927 | |
04e4e6ab LC |
9928 | @cindex X session |
9929 | ||
9930 | SLiM automatically looks for session types described by the @file{.desktop} | |
9931 | files in @file{/run/current-system/profile/share/xsessions} and allows users | |
9932 | to choose a session from the log-in screen using @kbd{F1}. Packages such as | |
9933 | @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files; | |
9934 | adding them to the system-wide set of packages automatically makes them | |
9935 | available at the log-in screen. | |
9936 | ||
9937 | In addition, @file{~/.xsession} files are honored. When available, | |
9938 | @file{~/.xsession} must be an executable that starts a window manager | |
9939 | and/or other X clients. | |
9940 | ||
cf4a9129 LC |
9941 | When @var{allow-empty-passwords?} is true, allow logins with an empty |
9942 | password. When @var{auto-login?} is true, log in automatically as | |
9943 | @var{default-user}. | |
0ecc3bf3 | 9944 | |
1068f26b | 9945 | If @var{theme} is @code{#f}, use the default log-in theme; otherwise |
0ecc3bf3 LC |
9946 | @var{theme} must be a gexp denoting the name of a directory containing the |
9947 | theme to use. In that case, @var{theme-name} specifies the name of the | |
9948 | theme. | |
cf4a9129 | 9949 | @end deffn |
4af2447e | 9950 | |
0ecc3bf3 LC |
9951 | @defvr {Scheme Variable} %default-theme |
9952 | @defvrx {Scheme Variable} %default-theme-name | |
9953 | The G-Expression denoting the default SLiM theme and its name. | |
9954 | @end defvr | |
9955 | ||
be1c2c54 | 9956 | @deffn {Scheme Procedure} xorg-start-command [#:guile] @ |
d1cdd7ba | 9957 | [#:configuration-file #f] [#:xorg-server @var{xorg-server}] |
f703413e | 9958 | Return a derivation that builds a @var{guile} script to start the X server |
d1cdd7ba LC |
9959 | from @var{xorg-server}. @var{configuration-file} is the server configuration |
9960 | file or a derivation that builds it; when omitted, the result of | |
9961 | @code{xorg-configuration-file} is used. | |
9962 | ||
9963 | Usually the X server is started by a login manager. | |
9964 | @end deffn | |
9965 | ||
be1c2c54 | 9966 | @deffn {Scheme Procedure} xorg-configuration-file @ |
12422c9d | 9967 | [#:drivers '()] [#:resolutions '()] [#:extra-config '()] |
d1cdd7ba LC |
9968 | Return a configuration file for the Xorg server containing search paths for |
9969 | all the common drivers. | |
f703413e LC |
9970 | |
9971 | @var{drivers} must be either the empty list, in which case Xorg chooses a | |
9972 | graphics driver automatically, or a list of driver names that will be tried in | |
d1cdd7ba | 9973 | this order---e.g., @code{(\"modesetting\" \"vesa\")}. |
d2e59637 LC |
9974 | |
9975 | Likewise, when @var{resolutions} is the empty list, Xorg chooses an | |
9976 | appropriate screen resolution; otherwise, it must be a list of | |
9977 | resolutions---e.g., @code{((1024 768) (640 480))}. | |
12422c9d LC |
9978 | |
9979 | Last, @var{extra-config} is a list of strings or objects appended to the | |
9980 | @code{text-file*} argument list. It is used to pass extra text to be added | |
9981 | verbatim to the configuration file. | |
f703413e | 9982 | @end deffn |
4af2447e | 9983 | |
6726282b LC |
9984 | @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{name}] |
9985 | Add @var{package}, a package for a screen-locker or screen-saver whose | |
9986 | command is @var{program}, to the set of setuid programs and add a PAM entry | |
9987 | for it. For example: | |
9988 | ||
9989 | @lisp | |
9990 | (screen-locker-service xlockmore "xlock") | |
9991 | @end lisp | |
9992 | ||
9993 | makes the good ol' XlockMore usable. | |
9994 | @end deffn | |
9995 | ||
9996 | ||
f2ec23d1 AW |
9997 | @node Printing Services |
9998 | @subsubsection Printing Services | |
9999 | ||
de322a5d | 10000 | @cindex printer support with CUPS |
f2ec23d1 AW |
10001 | The @code{(gnu services cups)} module provides a Guix service definition |
10002 | for the CUPS printing service. To add printer support to a GuixSD | |
10003 | system, add a @code{cups-service} to the operating system definition: | |
10004 | ||
10005 | @deffn {Scheme Variable} cups-service-type | |
10006 | The service type for the CUPS print server. Its value should be a valid | |
10007 | CUPS configuration (see below). For example: | |
10008 | @example | |
10009 | (service cups-service-type (cups-configuration)) | |
10010 | @end example | |
10011 | @end deffn | |
10012 | ||
10013 | The CUPS configuration controls the basic things about your CUPS | |
10014 | installation: what interfaces it listens on, what to do if a print job | |
10015 | fails, how much logging to do, and so on. To actually add a printer, | |
10016 | you have to visit the @url{http://localhost:631} URL, or use a tool such | |
10017 | as GNOME's printer configuration services. By default, configuring a | |
10018 | CUPS service will generate a self-signed certificate if needed, for | |
10019 | secure connections to the print server. | |
10020 | ||
de322a5d LC |
10021 | Suppose you want to enable the Web interface of CUPS and also add |
10022 | support for HP printers @i{via} the @code{hplip} package. You can do | |
10023 | that directly, like this (you need to use the @code{(gnu packages cups)} | |
10024 | module): | |
f2ec23d1 AW |
10025 | |
10026 | @example | |
10027 | (service cups-service-type | |
10028 | (cups-configuration | |
de322a5d LC |
10029 | (web-interface? #t) |
10030 | (extensions | |
10031 | (list cups-filters hplip)))) | |
f2ec23d1 AW |
10032 | @end example |
10033 | ||
10034 | The available configuration parameters follow. Each parameter | |
10035 | definition is preceded by its type; for example, @samp{string-list foo} | |
10036 | indicates that the @code{foo} parameter should be specified as a list of | |
10037 | strings. There is also a way to specify the configuration as a string, | |
10038 | if you have an old @code{cupsd.conf} file that you want to port over | |
10039 | from some other system; see the end for more details. | |
10040 | ||
10041 | @c The following documentation was initially generated by | |
10042 | @c (generate-documentation) in (gnu services cups). Manually maintained | |
10043 | @c documentation is better, so we shouldn't hesitate to edit below as | |
10044 | @c needed. However if the change you want to make to this documentation | |
10045 | @c can be done in an automated way, it's probably easier to change | |
10046 | @c (generate-documentation) than to make it below and have to deal with | |
10047 | @c the churn as CUPS updates. | |
10048 | ||
10049 | ||
10050 | Available @code{cups-configuration} fields are: | |
10051 | ||
10052 | @deftypevr {@code{cups-configuration} parameter} package cups | |
10053 | The CUPS package. | |
10054 | @end deftypevr | |
10055 | ||
10056 | @deftypevr {@code{cups-configuration} parameter} package-list extensions | |
10057 | Drivers and other extensions to the CUPS package. | |
10058 | @end deftypevr | |
10059 | ||
10060 | @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration | |
10061 | Configuration of where to write logs, what directories to use for print | |
10062 | spools, and related privileged configuration parameters. | |
10063 | ||
10064 | Available @code{files-configuration} fields are: | |
10065 | ||
10066 | @deftypevr {@code{files-configuration} parameter} log-location access-log | |
10067 | Defines the access log filename. Specifying a blank filename disables | |
10068 | access log generation. The value @code{stderr} causes log entries to be | |
10069 | sent to the standard error file when the scheduler is running in the | |
10070 | foreground, or to the system log daemon when run in the background. The | |
10071 | value @code{syslog} causes log entries to be sent to the system log | |
10072 | daemon. The server name may be included in filenames using the string | |
10073 | @code{%s}, as in @code{/var/log/cups/%s-access_log}. | |
10074 | ||
10075 | Defaults to @samp{"/var/log/cups/access_log"}. | |
10076 | @end deftypevr | |
10077 | ||
10078 | @deftypevr {@code{files-configuration} parameter} file-name cache-dir | |
10079 | Where CUPS should cache data. | |
10080 | ||
10081 | Defaults to @samp{"/var/cache/cups"}. | |
10082 | @end deftypevr | |
10083 | ||
10084 | @deftypevr {@code{files-configuration} parameter} string config-file-perm | |
10085 | Specifies the permissions for all configuration files that the scheduler | |
10086 | writes. | |
10087 | ||
10088 | Note that the permissions for the printers.conf file are currently | |
10089 | masked to only allow access from the scheduler user (typically root). | |
10090 | This is done because printer device URIs sometimes contain sensitive | |
10091 | authentication information that should not be generally known on the | |
10092 | system. There is no way to disable this security feature. | |
10093 | ||
10094 | Defaults to @samp{"0640"}. | |
10095 | @end deftypevr | |
10096 | ||
10097 | @deftypevr {@code{files-configuration} parameter} log-location error-log | |
10098 | Defines the error log filename. Specifying a blank filename disables | |
10099 | access log generation. The value @code{stderr} causes log entries to be | |
10100 | sent to the standard error file when the scheduler is running in the | |
10101 | foreground, or to the system log daemon when run in the background. The | |
10102 | value @code{syslog} causes log entries to be sent to the system log | |
10103 | daemon. The server name may be included in filenames using the string | |
10104 | @code{%s}, as in @code{/var/log/cups/%s-error_log}. | |
10105 | ||
10106 | Defaults to @samp{"/var/log/cups/error_log"}. | |
10107 | @end deftypevr | |
10108 | ||
10109 | @deftypevr {@code{files-configuration} parameter} string fatal-errors | |
10110 | Specifies which errors are fatal, causing the scheduler to exit. The | |
10111 | kind strings are: | |
10112 | ||
10113 | @table @code | |
10114 | @item none | |
10115 | No errors are fatal. | |
10116 | ||
10117 | @item all | |
10118 | All of the errors below are fatal. | |
10119 | ||
10120 | @item browse | |
10121 | Browsing initialization errors are fatal, for example failed connections | |
10122 | to the DNS-SD daemon. | |
10123 | ||
10124 | @item config | |
10125 | Configuration file syntax errors are fatal. | |
10126 | ||
10127 | @item listen | |
10128 | Listen or Port errors are fatal, except for IPv6 failures on the | |
10129 | loopback or @code{any} addresses. | |
10130 | ||
10131 | @item log | |
10132 | Log file creation or write errors are fatal. | |
10133 | ||
10134 | @item permissions | |
10135 | Bad startup file permissions are fatal, for example shared TLS | |
10136 | certificate and key files with world-read permissions. | |
10137 | @end table | |
10138 | ||
10139 | Defaults to @samp{"all -browse"}. | |
10140 | @end deftypevr | |
10141 | ||
10142 | @deftypevr {@code{files-configuration} parameter} boolean file-device? | |
10143 | Specifies whether the file pseudo-device can be used for new printer | |
10144 | queues. The URI @uref{file:///dev/null} is always allowed. | |
10145 | ||
10146 | Defaults to @samp{#f}. | |
10147 | @end deftypevr | |
10148 | ||
10149 | @deftypevr {@code{files-configuration} parameter} string group | |
10150 | Specifies the group name or ID that will be used when executing external | |
10151 | programs. | |
10152 | ||
10153 | Defaults to @samp{"lp"}. | |
10154 | @end deftypevr | |
10155 | ||
10156 | @deftypevr {@code{files-configuration} parameter} string log-file-perm | |
10157 | Specifies the permissions for all log files that the scheduler writes. | |
10158 | ||
10159 | Defaults to @samp{"0644"}. | |
10160 | @end deftypevr | |
10161 | ||
10162 | @deftypevr {@code{files-configuration} parameter} log-location page-log | |
10163 | Defines the page log filename. Specifying a blank filename disables | |
10164 | access log generation. The value @code{stderr} causes log entries to be | |
10165 | sent to the standard error file when the scheduler is running in the | |
10166 | foreground, or to the system log daemon when run in the background. The | |
10167 | value @code{syslog} causes log entries to be sent to the system log | |
10168 | daemon. The server name may be included in filenames using the string | |
10169 | @code{%s}, as in @code{/var/log/cups/%s-page_log}. | |
10170 | ||
10171 | Defaults to @samp{"/var/log/cups/page_log"}. | |
10172 | @end deftypevr | |
10173 | ||
10174 | @deftypevr {@code{files-configuration} parameter} string remote-root | |
10175 | Specifies the username that is associated with unauthenticated accesses | |
10176 | by clients claiming to be the root user. The default is @code{remroot}. | |
10177 | ||
10178 | Defaults to @samp{"remroot"}. | |
10179 | @end deftypevr | |
10180 | ||
10181 | @deftypevr {@code{files-configuration} parameter} file-name request-root | |
10182 | Specifies the directory that contains print jobs and other HTTP request | |
10183 | data. | |
10184 | ||
10185 | Defaults to @samp{"/var/spool/cups"}. | |
10186 | @end deftypevr | |
10187 | ||
10188 | @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing | |
10189 | Specifies the level of security sandboxing that is applied to print | |
10190 | filters, backends, and other child processes of the scheduler; either | |
10191 | @code{relaxed} or @code{strict}. This directive is currently only | |
10192 | used/supported on macOS. | |
10193 | ||
10194 | Defaults to @samp{strict}. | |
10195 | @end deftypevr | |
10196 | ||
10197 | @deftypevr {@code{files-configuration} parameter} file-name server-keychain | |
10198 | Specifies the location of TLS certificates and private keys. CUPS will | |
10199 | look for public and private keys in this directory: a @code{.crt} files | |
10200 | for PEM-encoded certificates and corresponding @code{.key} files for | |
10201 | PEM-encoded private keys. | |
10202 | ||
10203 | Defaults to @samp{"/etc/cups/ssl"}. | |
10204 | @end deftypevr | |
10205 | ||
10206 | @deftypevr {@code{files-configuration} parameter} file-name server-root | |
10207 | Specifies the directory containing the server configuration files. | |
10208 | ||
10209 | Defaults to @samp{"/etc/cups"}. | |
10210 | @end deftypevr | |
10211 | ||
10212 | @deftypevr {@code{files-configuration} parameter} boolean sync-on-close? | |
10213 | Specifies whether the scheduler calls fsync(2) after writing | |
10214 | configuration or state files. | |
10215 | ||
10216 | Defaults to @samp{#f}. | |
10217 | @end deftypevr | |
10218 | ||
10219 | @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group | |
10220 | Specifies the group(s) to use for @code{@@SYSTEM} group authentication. | |
10221 | @end deftypevr | |
10222 | ||
10223 | @deftypevr {@code{files-configuration} parameter} file-name temp-dir | |
10224 | Specifies the directory where temporary files are stored. | |
10225 | ||
10226 | Defaults to @samp{"/var/spool/cups/tmp"}. | |
10227 | @end deftypevr | |
10228 | ||
10229 | @deftypevr {@code{files-configuration} parameter} string user | |
10230 | Specifies the user name or ID that is used when running external | |
10231 | programs. | |
10232 | ||
10233 | Defaults to @samp{"lp"}. | |
10234 | @end deftypevr | |
10235 | @end deftypevr | |
10236 | ||
10237 | @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level | |
10238 | Specifies the logging level for the AccessLog file. The @code{config} | |
10239 | level logs when printers and classes are added, deleted, or modified and | |
10240 | when configuration files are accessed or updated. The @code{actions} | |
10241 | level logs when print jobs are submitted, held, released, modified, or | |
10242 | canceled, and any of the conditions for @code{config}. The @code{all} | |
10243 | level logs all requests. | |
10244 | ||
10245 | Defaults to @samp{actions}. | |
10246 | @end deftypevr | |
10247 | ||
10248 | @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs? | |
10249 | Specifies whether to purge job history data automatically when it is no | |
10250 | longer required for quotas. | |
10251 | ||
10252 | Defaults to @samp{#f}. | |
10253 | @end deftypevr | |
10254 | ||
10255 | @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols | |
10256 | Specifies which protocols to use for local printer sharing. | |
10257 | ||
10258 | Defaults to @samp{dnssd}. | |
10259 | @end deftypevr | |
10260 | ||
10261 | @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if? | |
10262 | Specifies whether the CUPS web interface is advertised. | |
10263 | ||
10264 | Defaults to @samp{#f}. | |
10265 | @end deftypevr | |
10266 | ||
10267 | @deftypevr {@code{cups-configuration} parameter} boolean browsing? | |
10268 | Specifies whether shared printers are advertised. | |
10269 | ||
10270 | Defaults to @samp{#f}. | |
10271 | @end deftypevr | |
10272 | ||
10273 | @deftypevr {@code{cups-configuration} parameter} string classification | |
10274 | Specifies the security classification of the server. Any valid banner | |
10275 | name can be used, including "classified", "confidential", "secret", | |
10276 | "topsecret", and "unclassified", or the banner can be omitted to disable | |
10277 | secure printing functions. | |
10278 | ||
10279 | Defaults to @samp{""}. | |
10280 | @end deftypevr | |
10281 | ||
10282 | @deftypevr {@code{cups-configuration} parameter} boolean classify-override? | |
10283 | Specifies whether users may override the classification (cover page) of | |
10284 | individual print jobs using the @code{job-sheets} option. | |
10285 | ||
10286 | Defaults to @samp{#f}. | |
10287 | @end deftypevr | |
10288 | ||
10289 | @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type | |
10290 | Specifies the default type of authentication to use. | |
10291 | ||
10292 | Defaults to @samp{Basic}. | |
10293 | @end deftypevr | |
10294 | ||
10295 | @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption | |
10296 | Specifies whether encryption will be used for authenticated requests. | |
10297 | ||
10298 | Defaults to @samp{Required}. | |
10299 | @end deftypevr | |
10300 | ||
10301 | @deftypevr {@code{cups-configuration} parameter} string default-language | |
10302 | Specifies the default language to use for text and web content. | |
10303 | ||
10304 | Defaults to @samp{"en"}. | |
10305 | @end deftypevr | |
10306 | ||
10307 | @deftypevr {@code{cups-configuration} parameter} string default-paper-size | |
10308 | Specifies the default paper size for new print queues. @samp{"Auto"} | |
10309 | uses a locale-specific default, while @samp{"None"} specifies there is | |
10310 | no default paper size. Specific size names are typically | |
10311 | @samp{"Letter"} or @samp{"A4"}. | |
10312 | ||
10313 | Defaults to @samp{"Auto"}. | |
10314 | @end deftypevr | |
10315 | ||
10316 | @deftypevr {@code{cups-configuration} parameter} string default-policy | |
10317 | Specifies the default access policy to use. | |
10318 | ||
10319 | Defaults to @samp{"default"}. | |
10320 | @end deftypevr | |
10321 | ||
10322 | @deftypevr {@code{cups-configuration} parameter} boolean default-shared? | |
10323 | Specifies whether local printers are shared by default. | |
10324 | ||
10325 | Defaults to @samp{#t}. | |
10326 | @end deftypevr | |
10327 | ||
10328 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval | |
10329 | Specifies the delay for updating of configuration and state files, in | |
10330 | seconds. A value of 0 causes the update to happen as soon as possible, | |
10331 | typically within a few milliseconds. | |
10332 | ||
10333 | Defaults to @samp{30}. | |
10334 | @end deftypevr | |
10335 | ||
10336 | @deftypevr {@code{cups-configuration} parameter} error-policy error-policy | |
10337 | Specifies what to do when an error occurs. Possible values are | |
10338 | @code{abort-job}, which will discard the failed print job; | |
10339 | @code{retry-job}, which will retry the job at a later time; | |
10340 | @code{retry-this-job}, which retries the failed job immediately; and | |
10341 | @code{stop-printer}, which stops the printer. | |
10342 | ||
10343 | Defaults to @samp{stop-printer}. | |
10344 | @end deftypevr | |
10345 | ||
10346 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit | |
10347 | Specifies the maximum cost of filters that are run concurrently, which | |
10348 | can be used to minimize disk, memory, and CPU resource problems. A | |
10349 | limit of 0 disables filter limiting. An average print to a | |
10350 | non-PostScript printer needs a filter limit of about 200. A PostScript | |
10351 | printer needs about half that (100). Setting the limit below these | |
10352 | thresholds will effectively limit the scheduler to printing a single job | |
10353 | at any time. | |
10354 | ||
10355 | Defaults to @samp{0}. | |
10356 | @end deftypevr | |
10357 | ||
10358 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice | |
10359 | Specifies the scheduling priority of filters that are run to print a | |
10360 | job. The nice value ranges from 0, the highest priority, to 19, the | |
10361 | lowest priority. | |
10362 | ||
10363 | Defaults to @samp{0}. | |
10364 | @end deftypevr | |
10365 | ||
10366 | @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups | |
10367 | Specifies whether to do reverse lookups on connecting clients. The | |
10368 | @code{double} setting causes @code{cupsd} to verify that the hostname | |
10369 | resolved from the address matches one of the addresses returned for that | |
10370 | hostname. Double lookups also prevent clients with unregistered | |
10371 | addresses from connecting to your server. Only set this option to | |
10372 | @code{#t} or @code{double} if absolutely required. | |
10373 | ||
10374 | Defaults to @samp{#f}. | |
10375 | @end deftypevr | |
10376 | ||
10377 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay | |
10378 | Specifies the number of seconds to wait before killing the filters and | |
10379 | backend associated with a canceled or held job. | |
10380 | ||
10381 | Defaults to @samp{30}. | |
10382 | @end deftypevr | |
10383 | ||
10384 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval | |
10385 | Specifies the interval between retries of jobs in seconds. This is | |
10386 | typically used for fax queues but can also be used with normal print | |
10387 | queues whose error policy is @code{retry-job} or | |
10388 | @code{retry-current-job}. | |
10389 | ||
10390 | Defaults to @samp{30}. | |
10391 | @end deftypevr | |
10392 | ||
10393 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit | |
10394 | Specifies the number of retries that are done for jobs. This is | |
10395 | typically used for fax queues but can also be used with normal print | |
10396 | queues whose error policy is @code{retry-job} or | |
10397 | @code{retry-current-job}. | |
10398 | ||
10399 | Defaults to @samp{5}. | |
10400 | @end deftypevr | |
10401 | ||
10402 | @deftypevr {@code{cups-configuration} parameter} boolean keep-alive? | |
10403 | Specifies whether to support HTTP keep-alive connections. | |
10404 | ||
10405 | Defaults to @samp{#t}. | |
10406 | @end deftypevr | |
10407 | ||
10408 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout | |
10409 | Specifies how long an idle client connection remains open, in seconds. | |
10410 | ||
10411 | Defaults to @samp{30}. | |
10412 | @end deftypevr | |
10413 | ||
10414 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body | |
10415 | Specifies the maximum size of print files, IPP requests, and HTML form | |
10416 | data. A limit of 0 disables the limit check. | |
10417 | ||
10418 | Defaults to @samp{0}. | |
10419 | @end deftypevr | |
10420 | ||
10421 | @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen | |
10422 | Listens on the specified interfaces for connections. Valid values are | |
10423 | of the form @var{address}:@var{port}, where @var{address} is either an | |
10424 | IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to | |
10425 | indicate all addresses. Values can also be file names of local UNIX | |
10426 | domain sockets. The Listen directive is similar to the Port directive | |
10427 | but allows you to restrict access to specific interfaces or networks. | |
10428 | @end deftypevr | |
10429 | ||
10430 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log | |
10431 | Specifies the number of pending connections that will be allowed. This | |
10432 | normally only affects very busy servers that have reached the MaxClients | |
10433 | limit, but can also be triggered by large numbers of simultaneous | |
10434 | connections. When the limit is reached, the operating system will | |
10435 | refuse additional connections until the scheduler can accept the pending | |
10436 | ones. | |
10437 | ||
10438 | Defaults to @samp{128}. | |
10439 | @end deftypevr | |
10440 | ||
10441 | @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls | |
10442 | Specifies a set of additional access controls. | |
10443 | ||
10444 | Available @code{location-access-controls} fields are: | |
10445 | ||
10446 | @deftypevr {@code{location-access-controls} parameter} file-name path | |
10447 | Specifies the URI path to which the access control applies. | |
10448 | @end deftypevr | |
10449 | ||
10450 | @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls | |
10451 | Access controls for all access to this path, in the same format as the | |
10452 | @code{access-controls} of @code{operation-access-control}. | |
10453 | ||
10454 | Defaults to @samp{()}. | |
10455 | @end deftypevr | |
10456 | ||
10457 | @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls | |
10458 | Access controls for method-specific access to this path. | |
10459 | ||
10460 | Defaults to @samp{()}. | |
10461 | ||
10462 | Available @code{method-access-controls} fields are: | |
10463 | ||
10464 | @deftypevr {@code{method-access-controls} parameter} boolean reverse? | |
10465 | If @code{#t}, apply access controls to all methods except the listed | |
10466 | methods. Otherwise apply to only the listed methods. | |
10467 | ||
10468 | Defaults to @samp{#f}. | |
10469 | @end deftypevr | |
10470 | ||
10471 | @deftypevr {@code{method-access-controls} parameter} method-list methods | |
10472 | Methods to which this access control applies. | |
10473 | ||
10474 | Defaults to @samp{()}. | |
10475 | @end deftypevr | |
10476 | ||
10477 | @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls | |
10478 | Access control directives, as a list of strings. Each string should be | |
10479 | one directive, such as "Order allow,deny". | |
10480 | ||
10481 | Defaults to @samp{()}. | |
10482 | @end deftypevr | |
10483 | @end deftypevr | |
10484 | @end deftypevr | |
10485 | ||
10486 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history | |
10487 | Specifies the number of debugging messages that are retained for logging | |
10488 | if an error occurs in a print job. Debug messages are logged regardless | |
10489 | of the LogLevel setting. | |
10490 | ||
10491 | Defaults to @samp{100}. | |
10492 | @end deftypevr | |
10493 | ||
10494 | @deftypevr {@code{cups-configuration} parameter} log-level log-level | |
10495 | Specifies the level of logging for the ErrorLog file. The value | |
10496 | @code{none} stops all logging while @code{debug2} logs everything. | |
10497 | ||
10498 | Defaults to @samp{info}. | |
10499 | @end deftypevr | |
10500 | ||
10501 | @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format | |
10502 | Specifies the format of the date and time in the log files. The value | |
10503 | @code{standard} logs whole seconds while @code{usecs} logs microseconds. | |
10504 | ||
10505 | Defaults to @samp{standard}. | |
10506 | @end deftypevr | |
10507 | ||
10508 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients | |
10509 | Specifies the maximum number of simultaneous clients that are allowed by | |
10510 | the scheduler. | |
10511 | ||
10512 | Defaults to @samp{100}. | |
10513 | @end deftypevr | |
10514 | ||
10515 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host | |
10516 | Specifies the maximum number of simultaneous clients that are allowed | |
10517 | from a single address. | |
10518 | ||
10519 | Defaults to @samp{100}. | |
10520 | @end deftypevr | |
10521 | ||
10522 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies | |
10523 | Specifies the maximum number of copies that a user can print of each | |
10524 | job. | |
10525 | ||
10526 | Defaults to @samp{9999}. | |
10527 | @end deftypevr | |
10528 | ||
10529 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time | |
10530 | Specifies the maximum time a job may remain in the @code{indefinite} | |
10531 | hold state before it is canceled. A value of 0 disables cancellation of | |
10532 | held jobs. | |
10533 | ||
10534 | Defaults to @samp{0}. | |
10535 | @end deftypevr | |
10536 | ||
10537 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs | |
10538 | Specifies the maximum number of simultaneous jobs that are allowed. Set | |
10539 | to 0 to allow an unlimited number of jobs. | |
10540 | ||
10541 | Defaults to @samp{500}. | |
10542 | @end deftypevr | |
10543 | ||
10544 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer | |
10545 | Specifies the maximum number of simultaneous jobs that are allowed per | |
10546 | printer. A value of 0 allows up to MaxJobs jobs per printer. | |
10547 | ||
10548 | Defaults to @samp{0}. | |
10549 | @end deftypevr | |
10550 | ||
10551 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user | |
10552 | Specifies the maximum number of simultaneous jobs that are allowed per | |
10553 | user. A value of 0 allows up to MaxJobs jobs per user. | |
10554 | ||
10555 | Defaults to @samp{0}. | |
10556 | @end deftypevr | |
10557 | ||
10558 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time | |
10559 | Specifies the maximum time a job may take to print before it is | |
10560 | canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs. | |
10561 | ||
10562 | Defaults to @samp{10800}. | |
10563 | @end deftypevr | |
10564 | ||
10565 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size | |
10566 | Specifies the maximum size of the log files before they are rotated, in | |
10567 | bytes. The value 0 disables log rotation. | |
10568 | ||
10569 | Defaults to @samp{1048576}. | |
10570 | @end deftypevr | |
10571 | ||
10572 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout | |
10573 | Specifies the maximum amount of time to allow between files in a | |
10574 | multiple file print job, in seconds. | |
10575 | ||
10576 | Defaults to @samp{300}. | |
10577 | @end deftypevr | |
10578 | ||
10579 | @deftypevr {@code{cups-configuration} parameter} string page-log-format | |
10580 | Specifies the format of PageLog lines. Sequences beginning with percent | |
10581 | (@samp{%}) characters are replaced with the corresponding information, | |
10582 | while all other characters are copied literally. The following percent | |
10583 | sequences are recognized: | |
10584 | ||
10585 | @table @samp | |
10586 | @item %% | |
10587 | insert a single percent character | |
10588 | ||
10589 | @item %@{name@} | |
10590 | insert the value of the specified IPP attribute | |
10591 | ||
10592 | @item %C | |
10593 | insert the number of copies for the current page | |
10594 | ||
10595 | @item %P | |
10596 | insert the current page number | |
10597 | ||
10598 | @item %T | |
10599 | insert the current date and time in common log format | |
10600 | ||
10601 | @item %j | |
10602 | insert the job ID | |
10603 | ||
10604 | @item %p | |
10605 | insert the printer name | |
10606 | ||
10607 | @item %u | |
10608 | insert the username | |
10609 | @end table | |
10610 | ||
10611 | A value of the empty string disables page logging. The string @code{%p | |
10612 | %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@} | |
10613 | %@{job-name@} %@{media@} %@{sides@}} creates a page log with the | |
10614 | standard items. | |
10615 | ||
10616 | Defaults to @samp{""}. | |
10617 | @end deftypevr | |
10618 | ||
10619 | @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables | |
10620 | Passes the specified environment variable(s) to child processes; a list | |
10621 | of strings. | |
10622 | ||
10623 | Defaults to @samp{()}. | |
10624 | @end deftypevr | |
10625 | ||
10626 | @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies | |
10627 | Specifies named access control policies. | |
10628 | ||
10629 | Available @code{policy-configuration} fields are: | |
10630 | ||
10631 | @deftypevr {@code{policy-configuration} parameter} string name | |
10632 | Name of the policy. | |
10633 | @end deftypevr | |
10634 | ||
10635 | @deftypevr {@code{policy-configuration} parameter} string job-private-access | |
10636 | Specifies an access list for a job's private values. @code{@@ACL} maps | |
10637 | to the printer's requesting-user-name-allowed or | |
10638 | requesting-user-name-denied values. @code{@@OWNER} maps to the job's | |
10639 | owner. @code{@@SYSTEM} maps to the groups listed for the | |
10640 | @code{system-group} field of the @code{files-config} configuration, | |
10641 | which is reified into the @code{cups-files.conf(5)} file. Other | |
10642 | possible elements of the access list include specific user names, and | |
10643 | @code{@@@var{group}} to indicate members of a specific group. The | |
10644 | access list may also be simply @code{all} or @code{default}. | |
10645 | ||
10646 | Defaults to @samp{"@@OWNER @@SYSTEM"}. | |
10647 | @end deftypevr | |
10648 | ||
10649 | @deftypevr {@code{policy-configuration} parameter} string job-private-values | |
10650 | Specifies the list of job values to make private, or @code{all}, | |
10651 | @code{default}, or @code{none}. | |
10652 | ||
10653 | Defaults to @samp{"job-name job-originating-host-name | |
10654 | job-originating-user-name phone"}. | |
10655 | @end deftypevr | |
10656 | ||
10657 | @deftypevr {@code{policy-configuration} parameter} string subscription-private-access | |
10658 | Specifies an access list for a subscription's private values. | |
10659 | @code{@@ACL} maps to the printer's requesting-user-name-allowed or | |
10660 | requesting-user-name-denied values. @code{@@OWNER} maps to the job's | |
10661 | owner. @code{@@SYSTEM} maps to the groups listed for the | |
10662 | @code{system-group} field of the @code{files-config} configuration, | |
10663 | which is reified into the @code{cups-files.conf(5)} file. Other | |
10664 | possible elements of the access list include specific user names, and | |
10665 | @code{@@@var{group}} to indicate members of a specific group. The | |
10666 | access list may also be simply @code{all} or @code{default}. | |
10667 | ||
10668 | Defaults to @samp{"@@OWNER @@SYSTEM"}. | |
10669 | @end deftypevr | |
10670 | ||
10671 | @deftypevr {@code{policy-configuration} parameter} string subscription-private-values | |
10672 | Specifies the list of job values to make private, or @code{all}, | |
10673 | @code{default}, or @code{none}. | |
10674 | ||
10675 | Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri | |
10676 | notify-subscriber-user-name notify-user-data"}. | |
10677 | @end deftypevr | |
10678 | ||
10679 | @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls | |
10680 | Access control by IPP operation. | |
10681 | ||
10682 | Defaults to @samp{()}. | |
10683 | @end deftypevr | |
10684 | @end deftypevr | |
10685 | ||
10686 | @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files | |
10687 | Specifies whether job files (documents) are preserved after a job is | |
10688 | printed. If a numeric value is specified, job files are preserved for | |
10689 | the indicated number of seconds after printing. Otherwise a boolean | |
10690 | value applies indefinitely. | |
10691 | ||
10692 | Defaults to @samp{86400}. | |
10693 | @end deftypevr | |
10694 | ||
10695 | @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history | |
10696 | Specifies whether the job history is preserved after a job is printed. | |
10697 | If a numeric value is specified, the job history is preserved for the | |
10698 | indicated number of seconds after printing. If @code{#t}, the job | |
10699 | history is preserved until the MaxJobs limit is reached. | |
10700 | ||
10701 | Defaults to @samp{#t}. | |
10702 | @end deftypevr | |
10703 | ||
10704 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout | |
10705 | Specifies the amount of time to wait for job completion before | |
10706 | restarting the scheduler. | |
10707 | ||
10708 | Defaults to @samp{30}. | |
10709 | @end deftypevr | |
10710 | ||
10711 | @deftypevr {@code{cups-configuration} parameter} string rip-cache | |
10712 | Specifies the maximum amount of memory to use when converting documents | |
10713 | into bitmaps for a printer. | |
10714 | ||
10715 | Defaults to @samp{"128m"}. | |
10716 | @end deftypevr | |
10717 | ||
10718 | @deftypevr {@code{cups-configuration} parameter} string server-admin | |
10719 | Specifies the email address of the server administrator. | |
10720 | ||
10721 | Defaults to @samp{"root@@localhost.localdomain"}. | |
10722 | @end deftypevr | |
10723 | ||
10724 | @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias | |
10725 | The ServerAlias directive is used for HTTP Host header validation when | |
10726 | clients connect to the scheduler from external interfaces. Using the | |
10727 | special name @code{*} can expose your system to known browser-based DNS | |
10728 | rebinding attacks, even when accessing sites through a firewall. If the | |
10729 | auto-discovery of alternate names does not work, we recommend listing | |
10730 | each alternate name with a ServerAlias directive instead of using | |
10731 | @code{*}. | |
10732 | ||
10733 | Defaults to @samp{*}. | |
10734 | @end deftypevr | |
10735 | ||
10736 | @deftypevr {@code{cups-configuration} parameter} string server-name | |
10737 | Specifies the fully-qualified host name of the server. | |
10738 | ||
10739 | Defaults to @samp{"localhost"}. | |
10740 | @end deftypevr | |
10741 | ||
10742 | @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens | |
10743 | Specifies what information is included in the Server header of HTTP | |
10744 | responses. @code{None} disables the Server header. @code{ProductOnly} | |
10745 | reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor} | |
10746 | reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}. | |
10747 | @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is | |
10748 | the output of the @code{uname} command. @code{Full} reports @code{CUPS | |
10749 | 2.0.0 (@var{uname}) IPP/2.0}. | |
10750 | ||
10751 | Defaults to @samp{Minimal}. | |
10752 | @end deftypevr | |
10753 | ||
10754 | @deftypevr {@code{cups-configuration} parameter} string set-env | |
10755 | Set the specified environment variable to be passed to child processes. | |
10756 | ||
10757 | Defaults to @samp{"variable value"}. | |
10758 | @end deftypevr | |
10759 | ||
10760 | @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen | |
10761 | Listens on the specified interfaces for encrypted connections. Valid | |
10762 | values are of the form @var{address}:@var{port}, where @var{address} is | |
10763 | either an IPv6 address enclosed in brackets, an IPv4 address, or | |
10764 | @code{*} to indicate all addresses. | |
10765 | ||
10766 | Defaults to @samp{()}. | |
10767 | @end deftypevr | |
10768 | ||
10769 | @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options | |
10770 | Sets encryption options. By default, CUPS only supports encryption | |
10771 | using TLS v1.0 or higher using known secure cipher suites. The | |
10772 | @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are | |
10773 | required for some older clients that do not implement newer ones. The | |
10774 | @code{AllowSSL3} option enables SSL v3.0, which is required for some | |
10775 | older clients that do not support TLS v1.0. | |
10776 | ||
10777 | Defaults to @samp{()}. | |
10778 | @end deftypevr | |
10779 | ||
10780 | @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance? | |
10781 | Specifies whether the scheduler requires clients to strictly adhere to | |
10782 | the IPP specifications. | |
10783 | ||
10784 | Defaults to @samp{#f}. | |
10785 | @end deftypevr | |
10786 | ||
10787 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout | |
10788 | Specifies the HTTP request timeout, in seconds. | |
10789 | ||
10790 | Defaults to @samp{300}. | |
10791 | ||
10792 | @end deftypevr | |
10793 | ||
10794 | @deftypevr {@code{cups-configuration} parameter} boolean web-interface? | |
10795 | Specifies whether the web interface is enabled. | |
10796 | ||
10797 | Defaults to @samp{#f}. | |
10798 | @end deftypevr | |
10799 | ||
10800 | At this point you're probably thinking ``oh dear, Guix manual, I like | |
10801 | you but you can stop already with the configuration options''. Indeed. | |
10802 | However, one more point: it could be that you have an existing | |
10803 | @code{cupsd.conf} that you want to use. In that case, you can pass an | |
10804 | @code{opaque-cups-configuration} as the configuration of a | |
10805 | @code{cups-service-type}. | |
10806 | ||
10807 | Available @code{opaque-cups-configuration} fields are: | |
10808 | ||
10809 | @deftypevr {@code{opaque-cups-configuration} parameter} package cups | |
10810 | The CUPS package. | |
10811 | @end deftypevr | |
10812 | ||
10813 | @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf | |
10814 | The contents of the @code{cupsd.conf}, as a string. | |
10815 | @end deftypevr | |
10816 | ||
10817 | @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf | |
10818 | The contents of the @code{cups-files.conf} file, as a string. | |
10819 | @end deftypevr | |
10820 | ||
10821 | For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in | |
10822 | strings of the same name, you could instantiate a CUPS service like | |
10823 | this: | |
10824 | ||
10825 | @example | |
10826 | (service cups-service-type | |
10827 | (opaque-cups-configuration | |
10828 | (cupsd.conf cupsd.conf) | |
10829 | (cups-files.conf cups-files.conf))) | |
10830 | @end example | |
10831 | ||
10832 | ||
fe1a39d3 LC |
10833 | @node Desktop Services |
10834 | @subsubsection Desktop Services | |
aa4ed923 | 10835 | |
fe1a39d3 LC |
10836 | The @code{(gnu services desktop)} module provides services that are |
10837 | usually useful in the context of a ``desktop'' setup---that is, on a | |
10838 | machine running a graphical display server, possibly with graphical user | |
7a2413e4 AW |
10839 | interfaces, etc. It also defines services that provide specific desktop |
10840 | environments like GNOME and XFCE. | |
aa4ed923 | 10841 | |
4467be21 LC |
10842 | To simplify things, the module defines a variable containing the set of |
10843 | services that users typically expect on a machine with a graphical | |
10844 | environment and networking: | |
10845 | ||
10846 | @defvr {Scheme Variable} %desktop-services | |
10847 | This is a list of services that builds upon @var{%base-services} and | |
1068f26b | 10848 | adds or adjusts services for a typical ``desktop'' setup. |
4467be21 LC |
10849 | |
10850 | In particular, it adds a graphical login manager (@pxref{X Window, | |
6726282b LC |
10851 | @code{slim-service}}), screen lockers, |
10852 | a network management tool (@pxref{Networking | |
4467be21 | 10853 | Services, @code{wicd-service}}), energy and color management services, |
4650a77e | 10854 | the @code{elogind} login and seat manager, the Polkit privilege service, |
cee32ee4 AW |
10855 | the GeoClue location service, an NTP client (@pxref{Networking |
10856 | Services}), the Avahi daemon, and has the name service switch service | |
10857 | configured to be able to use @code{nss-mdns} (@pxref{Name Service | |
10858 | Switch, mDNS}). | |
4467be21 LC |
10859 | @end defvr |
10860 | ||
10861 | The @var{%desktop-services} variable can be used as the @code{services} | |
10862 | field of an @code{operating-system} declaration (@pxref{operating-system | |
10863 | Reference, @code{services}}). | |
10864 | ||
7a2413e4 AW |
10865 | Additionally, the @code{gnome-desktop-service} and |
10866 | @code{xfce-desktop-service} procedures can add GNOME and/or XFCE to a | |
10867 | system. To ``add GNOME'' means that system-level services like the | |
10868 | backlight adjustment helpers and the power management utilities are | |
10869 | added to the system, extending @code{polkit} and @code{dbus} | |
10870 | appropriately, allowing GNOME to operate with elevated privileges on a | |
10871 | limited number of special-purpose system interfaces. Additionally, | |
10872 | adding a service made by @code{gnome-desktop-service} adds the GNOME | |
10873 | metapackage to the system profile. Likewise, adding the XFCE service | |
10874 | not only adds the @code{xfce} metapackage to the system profile, but it | |
10875 | also gives the Thunar file manager the ability to open a ``root-mode'' | |
10876 | file management window, if the user authenticates using the | |
10877 | administrator's password via the standard polkit graphical interface. | |
10878 | ||
10879 | @deffn {Scheme Procedure} gnome-desktop-service | |
10880 | Return a service that adds the @code{gnome} package to the system | |
10881 | profile, and extends polkit with the actions from | |
10882 | @code{gnome-settings-daemon}. | |
10883 | @end deffn | |
10884 | ||
10885 | @deffn {Scheme Procedure} xfce-desktop-service | |
10886 | Return a service that adds the @code{xfce} package to the system profile, | |
5741e3e5 | 10887 | and extends polkit with the ability for @code{thunar} to manipulate the |
7a2413e4 AW |
10888 | file system as root from within a user session, after the user has |
10889 | authenticated with the administrator's password. | |
10890 | @end deffn | |
10891 | ||
10892 | Because the GNOME and XFCE desktop services pull in so many packages, | |
10893 | the default @code{%desktop-services} variable doesn't include either of | |
10894 | them by default. To add GNOME or XFCE, just @code{cons} them onto | |
10895 | @code{%desktop-services} in the @code{services} field of your | |
10896 | @code{operating-system}: | |
10897 | ||
10898 | @example | |
10899 | (use-modules (gnu)) | |
10900 | (use-service-modules desktop) | |
10901 | (operating-system | |
10902 | ... | |
10903 | ;; cons* adds items to the list given as its last argument. | |
10904 | (services (cons* (gnome-desktop-service) | |
10905 | (xfce-desktop-service) | |
10906 | %desktop-services)) | |
10907 | ...) | |
10908 | @end example | |
10909 | ||
10910 | These desktop environments will then be available as options in the | |
10911 | graphical login window. | |
10912 | ||
10913 | The actual service definitions included in @code{%desktop-services} and | |
10914 | provided by @code{(gnu services dbus)} and @code{(gnu services desktop)} | |
10915 | are described below. | |
4467be21 | 10916 | |
0adfe95a | 10917 | @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()] |
fe1a39d3 LC |
10918 | Return a service that runs the ``system bus'', using @var{dbus}, with |
10919 | support for @var{services}. | |
aa4ed923 | 10920 | |
fe1a39d3 LC |
10921 | @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication |
10922 | facility. Its system bus is used to allow system services to communicate | |
1068f26b | 10923 | and to be notified of system-wide events. |
aa4ed923 | 10924 | |
fe1a39d3 LC |
10925 | @var{services} must be a list of packages that provide an |
10926 | @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration | |
10927 | and policy files. For example, to allow avahi-daemon to use the system bus, | |
10928 | @var{services} must be equal to @code{(list avahi)}. | |
aa4ed923 AK |
10929 | @end deffn |
10930 | ||
0adfe95a | 10931 | @deffn {Scheme Procedure} elogind-service [#:config @var{config}] |
4650a77e AW |
10932 | Return a service that runs the @code{elogind} login and |
10933 | seat management daemon. @uref{https://github.com/andywingo/elogind, | |
10934 | Elogind} exposes a D-Bus interface that can be used to know which users | |
10935 | are logged in, know what kind of sessions they have open, suspend the | |
10936 | system, inhibit system suspend, reboot the system, and other tasks. | |
10937 | ||
10938 | Elogind handles most system-level power events for a computer, for | |
10939 | example suspending the system when a lid is closed, or shutting it down | |
10940 | when the power button is pressed. | |
10941 | ||
10942 | The @var{config} keyword argument specifies the configuration for | |
1068f26b | 10943 | elogind, and should be the result of an @code{(elogind-configuration |
4650a77e AW |
10944 | (@var{parameter} @var{value})...)} invocation. Available parameters and |
10945 | their default values are: | |
10946 | ||
10947 | @table @code | |
10948 | @item kill-user-processes? | |
10949 | @code{#f} | |
10950 | @item kill-only-users | |
10951 | @code{()} | |
10952 | @item kill-exclude-users | |
10953 | @code{("root")} | |
10954 | @item inhibit-delay-max-seconds | |
10955 | @code{5} | |
10956 | @item handle-power-key | |
10957 | @code{poweroff} | |
10958 | @item handle-suspend-key | |
10959 | @code{suspend} | |
10960 | @item handle-hibernate-key | |
10961 | @code{hibernate} | |
10962 | @item handle-lid-switch | |
10963 | @code{suspend} | |
10964 | @item handle-lid-switch-docked | |
10965 | @code{ignore} | |
10966 | @item power-key-ignore-inhibited? | |
10967 | @code{#f} | |
10968 | @item suspend-key-ignore-inhibited? | |
10969 | @code{#f} | |
10970 | @item hibernate-key-ignore-inhibited? | |
10971 | @code{#f} | |
10972 | @item lid-switch-ignore-inhibited? | |
10973 | @code{#t} | |
10974 | @item holdoff-timeout-seconds | |
10975 | @code{30} | |
10976 | @item idle-action | |
10977 | @code{ignore} | |
10978 | @item idle-action-seconds | |
10979 | @code{(* 30 60)} | |
10980 | @item runtime-directory-size-percent | |
10981 | @code{10} | |
10982 | @item runtime-directory-size | |
10983 | @code{#f} | |
10984 | @item remove-ipc? | |
10985 | @code{#t} | |
10986 | @item suspend-state | |
10987 | @code{("mem" "standby" "freeze")} | |
10988 | @item suspend-mode | |
10989 | @code{()} | |
10990 | @item hibernate-state | |
10991 | @code{("disk")} | |
10992 | @item hibernate-mode | |
10993 | @code{("platform" "shutdown")} | |
10994 | @item hybrid-sleep-state | |
10995 | @code{("disk")} | |
10996 | @item hybrid-sleep-mode | |
10997 | @code{("suspend" "platform" "shutdown")} | |
10998 | @end table | |
10999 | @end deffn | |
11000 | ||
be1c2c54 | 11001 | @deffn {Scheme Procedure} polkit-service @ |
4650a77e | 11002 | [#:polkit @var{polkit}] |
222e3319 LC |
11003 | Return a service that runs the |
11004 | @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege | |
11005 | management service}, which allows system administrators to grant access to | |
11006 | privileged operations in a structured way. By querying the Polkit service, a | |
11007 | privileged system component can know when it should grant additional | |
11008 | capabilities to ordinary users. For example, an ordinary user can be granted | |
11009 | the capability to suspend the system if the user is logged in locally. | |
4650a77e AW |
11010 | @end deffn |
11011 | ||
be1c2c54 | 11012 | @deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @ |
be234128 AW |
11013 | [#:watts-up-pro? #f] @ |
11014 | [#:poll-batteries? #t] @ | |
11015 | [#:ignore-lid? #f] @ | |
11016 | [#:use-percentage-for-policy? #f] @ | |
11017 | [#:percentage-low 10] @ | |
11018 | [#:percentage-critical 3] @ | |
11019 | [#:percentage-action 2] @ | |
11020 | [#:time-low 1200] @ | |
11021 | [#:time-critical 300] @ | |
11022 | [#:time-action 120] @ | |
11023 | [#:critical-power-action 'hybrid-sleep] | |
11024 | Return a service that runs @uref{http://upower.freedesktop.org/, | |
11025 | @command{upowerd}}, a system-wide monitor for power consumption and battery | |
11026 | levels, with the given configuration settings. It implements the | |
11027 | @code{org.freedesktop.UPower} D-Bus interface, and is notably used by | |
11028 | GNOME. | |
11029 | @end deffn | |
11030 | ||
2b9e0a94 LC |
11031 | @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}] |
11032 | Return a service for @uref{http://udisks.freedesktop.org/docs/latest/, | |
11033 | UDisks}, a @dfn{disk management} daemon that provides user interfaces with | |
11034 | notifications and ways to mount/unmount disks. Programs that talk to UDisks | |
11035 | include the @command{udisksctl} command, part of UDisks, and GNOME Disks. | |
11036 | @end deffn | |
11037 | ||
be1c2c54 | 11038 | @deffn {Scheme Procedure} colord-service [#:colord @var{colord}] |
7ce597ff AW |
11039 | Return a service that runs @command{colord}, a system service with a D-Bus |
11040 | interface to manage the color profiles of input and output devices such as | |
11041 | screens and scanners. It is notably used by the GNOME Color Manager graphical | |
11042 | tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web | |
11043 | site} for more information. | |
11044 | @end deffn | |
11045 | ||
cee32ee4 | 11046 | @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()] |
1068f26b | 11047 | Return a configuration allowing an application to access GeoClue |
cee32ee4 AW |
11048 | location data. @var{name} is the Desktop ID of the application, without |
11049 | the @code{.desktop} part. If @var{allowed?} is true, the application | |
11050 | will have access to location information by default. The boolean | |
1068f26b | 11051 | @var{system?} value indicates whether an application is a system component |
cee32ee4 AW |
11052 | or not. Finally @var{users} is a list of UIDs of all users for which |
11053 | this application is allowed location info access. An empty users list | |
11054 | means that all users are allowed. | |
11055 | @end deffn | |
11056 | ||
11057 | @defvr {Scheme Variable} %standard-geoclue-applications | |
11058 | The standard list of well-known GeoClue application configurations, | |
1068f26b AE |
11059 | granting authority to the GNOME date-and-time utility to ask for the |
11060 | current location in order to set the time zone, and allowing the | |
11061 | IceCat and Epiphany web browsers to request location information. | |
11062 | IceCat and Epiphany both query the user before allowing a web page to | |
cee32ee4 AW |
11063 | know the user's location. |
11064 | @end defvr | |
11065 | ||
be1c2c54 | 11066 | @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @ |
cee32ee4 AW |
11067 | [#:whitelist '()] @ |
11068 | [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @ | |
11069 | [#:submit-data? #f] | |
11070 | [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @ | |
11071 | [#:submission-nick "geoclue"] @ | |
11072 | [#:applications %standard-geoclue-applications] | |
11073 | Return a service that runs the GeoClue location service. This service | |
11074 | provides a D-Bus interface to allow applications to request access to a | |
11075 | user's physical location, and optionally to add information to online | |
11076 | location databases. See | |
11077 | @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue | |
11078 | web site} for more information. | |
11079 | @end deffn | |
11080 | ||
922e21f4 SB |
11081 | @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] |
11082 | Return a service that runs the @command{bluetoothd} daemon, which manages | |
11083 | all the Bluetooth devices and provides a number of D-Bus interfaces. | |
11084 | ||
11085 | Users need to be in the @code{lp} group to access the D-Bus service. | |
11086 | @end deffn | |
11087 | ||
105369a4 DT |
11088 | @node Database Services |
11089 | @subsubsection Database Services | |
11090 | ||
e32171ee JD |
11091 | @cindex database |
11092 | @cindex SQL | |
6575183b | 11093 | The @code{(gnu services databases)} module provides the following services. |
105369a4 | 11094 | |
be1c2c54 | 11095 | @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @ |
2d3d5cc5 | 11096 | [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @ |
e05b780a | 11097 | [#:port 5432] [#:locale ``en_US.utf8''] |
105369a4 DT |
11098 | Return a service that runs @var{postgresql}, the PostgreSQL database |
11099 | server. | |
11100 | ||
e05b780a CB |
11101 | The PostgreSQL daemon loads its runtime configuration from @var{config-file}, |
11102 | creates a database cluster with @var{locale} as the default | |
11103 | locale, stored in @var{data-directory}. It then listens on @var{port}. | |
105369a4 | 11104 | @end deffn |
fe1a39d3 | 11105 | |
6575183b SB |
11106 | @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)] |
11107 | Return a service that runs @command{mysqld}, the MySQL or MariaDB | |
11108 | database server. | |
11109 | ||
11110 | The optional @var{config} argument specifies the configuration for | |
c940b8e6 | 11111 | @command{mysqld}, which should be a @code{<mysql-configuration>} object. |
6575183b SB |
11112 | @end deffn |
11113 | ||
11114 | @deftp {Data Type} mysql-configuration | |
11115 | Data type representing the configuration of @var{mysql-service}. | |
11116 | ||
11117 | @table @asis | |
11118 | @item @code{mysql} (default: @var{mariadb}) | |
11119 | Package object of the MySQL database server, can be either @var{mariadb} | |
11120 | or @var{mysql}. | |
11121 | ||
7414de0a | 11122 | For MySQL, a temporary root password will be displayed at activation time. |
6575183b | 11123 | For MariaDB, the root password is empty. |
4b41febf CB |
11124 | |
11125 | @item @code{port} (default: @code{3306}) | |
11126 | TCP port on which the database server listens for incoming connections. | |
6575183b SB |
11127 | @end table |
11128 | @end deftp | |
11129 | ||
67cadaca CB |
11130 | @defvr {Scheme Variable} redis-service-type |
11131 | This is the service type for the @uref{https://redis.io/, Redis} | |
11132 | key/value store, whose value is a @code{redis-configuration} object. | |
11133 | @end defvr | |
11134 | ||
11135 | @deftp {Data Type} redis-configuration | |
11136 | Data type representing the configuration of redis. | |
11137 | ||
11138 | @table @asis | |
11139 | @item @code{redis} (default: @code{redis}) | |
11140 | The Redis package to use. | |
11141 | ||
11142 | @item @code{bind} (default: @code{"127.0.0.1"}) | |
11143 | Network interface on which to listen. | |
11144 | ||
11145 | @item @code{port} (default: @code{6379}) | |
11146 | Port on which to accept connections on, a value of 0 will disable | |
9fc221b5 | 11147 | listening on a TCP socket. |
67cadaca CB |
11148 | |
11149 | @item @code{working-directory} (default: @code{"/var/lib/redis"}) | |
11150 | Directory in which to store the database and related files. | |
11151 | @end table | |
11152 | @end deftp | |
11153 | ||
d8c18af8 AW |
11154 | @node Mail Services |
11155 | @subsubsection Mail Services | |
11156 | ||
e32171ee JD |
11157 | @cindex mail |
11158 | @cindex email | |
d8c18af8 | 11159 | The @code{(gnu services mail)} module provides Guix service definitions |
f88371e8 SB |
11160 | for email services: IMAP, POP3, and LMTP servers, as well as mail |
11161 | transport agents (MTAs). Lots of acronyms! These services are detailed | |
11162 | in the subsections below. | |
d8c18af8 | 11163 | |
f88371e8 | 11164 | @subsubheading Dovecot Service |
d8c18af8 AW |
11165 | |
11166 | @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)] | |
11167 | Return a service that runs the Dovecot IMAP/POP3/LMTP mail server. | |
11168 | @end deffn | |
11169 | ||
1068f26b | 11170 | By default, Dovecot does not need much configuration; the default |
d8c18af8 AW |
11171 | configuration object created by @code{(dovecot-configuration)} will |
11172 | suffice if your mail is delivered to @code{~/Maildir}. A self-signed | |
11173 | certificate will be generated for TLS-protected connections, though | |
11174 | Dovecot will also listen on cleartext ports by default. There are a | |
1068f26b | 11175 | number of options, though, which mail administrators might need to change, |
d8c18af8 AW |
11176 | and as is the case with other services, Guix allows the system |
11177 | administrator to specify these parameters via a uniform Scheme interface. | |
11178 | ||
11179 | For example, to specify that mail is located at @code{maildir~/.mail}, | |
11180 | one would instantiate the Dovecot service like this: | |
11181 | ||
11182 | @example | |
11183 | (dovecot-service #:config | |
11184 | (dovecot-configuration | |
11185 | (mail-location "maildir:~/.mail"))) | |
11186 | @end example | |
11187 | ||
11188 | The available configuration parameters follow. Each parameter | |
11189 | definition is preceded by its type; for example, @samp{string-list foo} | |
11190 | indicates that the @code{foo} parameter should be specified as a list of | |
11191 | strings. There is also a way to specify the configuration as a string, | |
11192 | if you have an old @code{dovecot.conf} file that you want to port over | |
11193 | from some other system; see the end for more details. | |
11194 | ||
11195 | @c The following documentation was initially generated by | |
11196 | @c (generate-documentation) in (gnu services mail). Manually maintained | |
11197 | @c documentation is better, so we shouldn't hesitate to edit below as | |
11198 | @c needed. However if the change you want to make to this documentation | |
11199 | @c can be done in an automated way, it's probably easier to change | |
11200 | @c (generate-documentation) than to make it below and have to deal with | |
11201 | @c the churn as dovecot updates. | |
11202 | ||
11203 | Available @code{dovecot-configuration} fields are: | |
11204 | ||
11205 | @deftypevr {@code{dovecot-configuration} parameter} package dovecot | |
11206 | The dovecot package. | |
11207 | @end deftypevr | |
11208 | ||
11209 | @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen | |
1068f26b AE |
11210 | A list of IPs or hosts where to listen for connections. @samp{*} |
11211 | listens on all IPv4 interfaces, @samp{::} listens on all IPv6 | |
d8c18af8 AW |
11212 | interfaces. If you want to specify non-default ports or anything more |
11213 | complex, customize the address and port fields of the | |
11214 | @samp{inet-listener} of the specific services you are interested in. | |
11215 | @end deftypevr | |
11216 | ||
11217 | @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols | |
11218 | List of protocols we want to serve. Available protocols include | |
11219 | @samp{imap}, @samp{pop3}, and @samp{lmtp}. | |
11220 | ||
11221 | Available @code{protocol-configuration} fields are: | |
11222 | ||
11223 | @deftypevr {@code{protocol-configuration} parameter} string name | |
11224 | The name of the protocol. | |
11225 | @end deftypevr | |
11226 | ||
11227 | @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path | |
1068f26b | 11228 | UNIX socket path to the master authentication server to find users. |
d8c18af8 | 11229 | This is used by imap (for shared users) and lda. |
1068f26b | 11230 | It defaults to @samp{"/var/run/dovecot/auth-userdb"}. |
d8c18af8 AW |
11231 | @end deftypevr |
11232 | ||
11233 | @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins | |
11234 | Space separated list of plugins to load. | |
11235 | @end deftypevr | |
11236 | ||
11237 | @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections | |
11238 | Maximum number of IMAP connections allowed for a user from each IP | |
11239 | address. NOTE: The username is compared case-sensitively. | |
11240 | Defaults to @samp{10}. | |
11241 | @end deftypevr | |
11242 | ||
11243 | @end deftypevr | |
11244 | ||
11245 | @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services | |
11246 | List of services to enable. Available services include @samp{imap}, | |
11247 | @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and | |
11248 | @samp{lmtp}. | |
11249 | ||
11250 | Available @code{service-configuration} fields are: | |
11251 | ||
11252 | @deftypevr {@code{service-configuration} parameter} string kind | |
11253 | The service kind. Valid values include @code{director}, | |
11254 | @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap}, | |
11255 | @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict}, | |
11256 | @code{tcpwrap}, @code{quota-warning}, or anything else. | |
11257 | @end deftypevr | |
11258 | ||
11259 | @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners | |
1068f26b | 11260 | Listeners for the service. A listener is either a |
d8c18af8 AW |
11261 | @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or |
11262 | an @code{inet-listener-configuration}. | |
11263 | Defaults to @samp{()}. | |
11264 | ||
11265 | Available @code{unix-listener-configuration} fields are: | |
11266 | ||
eba56076 CL |
11267 | @deftypevr {@code{unix-listener-configuration} parameter} string path |
11268 | Path to the file, relative to @code{base-dir} field. This is also used as | |
11269 | the section name. | |
d8c18af8 AW |
11270 | @end deftypevr |
11271 | ||
11272 | @deftypevr {@code{unix-listener-configuration} parameter} string mode | |
11273 | The access mode for the socket. | |
11274 | Defaults to @samp{"0600"}. | |
11275 | @end deftypevr | |
11276 | ||
11277 | @deftypevr {@code{unix-listener-configuration} parameter} string user | |
f9b9a033 | 11278 | The user to own the socket. |
d8c18af8 AW |
11279 | Defaults to @samp{""}. |
11280 | @end deftypevr | |
11281 | ||
11282 | @deftypevr {@code{unix-listener-configuration} parameter} string group | |
11283 | The group to own the socket. | |
11284 | Defaults to @samp{""}. | |
11285 | @end deftypevr | |
11286 | ||
11287 | ||
11288 | Available @code{fifo-listener-configuration} fields are: | |
11289 | ||
eba56076 CL |
11290 | @deftypevr {@code{fifo-listener-configuration} parameter} string path |
11291 | Path to the file, relative to @code{base-dir} field. This is also used as | |
11292 | the section name. | |
d8c18af8 AW |
11293 | @end deftypevr |
11294 | ||
11295 | @deftypevr {@code{fifo-listener-configuration} parameter} string mode | |
11296 | The access mode for the socket. | |
11297 | Defaults to @samp{"0600"}. | |
11298 | @end deftypevr | |
11299 | ||
11300 | @deftypevr {@code{fifo-listener-configuration} parameter} string user | |
f9b9a033 | 11301 | The user to own the socket. |
d8c18af8 AW |
11302 | Defaults to @samp{""}. |
11303 | @end deftypevr | |
11304 | ||
11305 | @deftypevr {@code{fifo-listener-configuration} parameter} string group | |
11306 | The group to own the socket. | |
11307 | Defaults to @samp{""}. | |
11308 | @end deftypevr | |
11309 | ||
11310 | ||
11311 | Available @code{inet-listener-configuration} fields are: | |
11312 | ||
11313 | @deftypevr {@code{inet-listener-configuration} parameter} string protocol | |
11314 | The protocol to listen for. | |
11315 | @end deftypevr | |
11316 | ||
11317 | @deftypevr {@code{inet-listener-configuration} parameter} string address | |
11318 | The address on which to listen, or empty for all addresses. | |
11319 | Defaults to @samp{""}. | |
11320 | @end deftypevr | |
11321 | ||
11322 | @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port | |
11323 | The port on which to listen. | |
11324 | @end deftypevr | |
11325 | ||
11326 | @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl? | |
11327 | Whether to use SSL for this service; @samp{yes}, @samp{no}, or | |
11328 | @samp{required}. | |
11329 | Defaults to @samp{#t}. | |
11330 | @end deftypevr | |
11331 | ||
11332 | @end deftypevr | |
11333 | ||
11334 | @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count | |
11335 | Number of connections to handle before starting a new process. | |
11336 | Typically the only useful values are 0 (unlimited) or 1. 1 is more | |
11337 | secure, but 0 is faster. <doc/wiki/LoginProcess.txt>. | |
11338 | Defaults to @samp{1}. | |
11339 | @end deftypevr | |
11340 | ||
11341 | @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail | |
11342 | Number of processes to always keep waiting for more connections. | |
11343 | Defaults to @samp{0}. | |
11344 | @end deftypevr | |
11345 | ||
11346 | @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit | |
11347 | If you set @samp{service-count 0}, you probably need to grow | |
11348 | this. | |
11349 | Defaults to @samp{256000000}. | |
11350 | @end deftypevr | |
11351 | ||
11352 | @end deftypevr | |
11353 | ||
11354 | @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict | |
11355 | Dict configuration, as created by the @code{dict-configuration} | |
11356 | constructor. | |
11357 | ||
11358 | Available @code{dict-configuration} fields are: | |
11359 | ||
11360 | @deftypevr {@code{dict-configuration} parameter} free-form-fields entries | |
11361 | A list of key-value pairs that this dict should hold. | |
11362 | Defaults to @samp{()}. | |
11363 | @end deftypevr | |
11364 | ||
11365 | @end deftypevr | |
11366 | ||
11367 | @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs | |
1068f26b | 11368 | A list of passdb configurations, each one created by the |
d8c18af8 AW |
11369 | @code{passdb-configuration} constructor. |
11370 | ||
11371 | Available @code{passdb-configuration} fields are: | |
11372 | ||
11373 | @deftypevr {@code{passdb-configuration} parameter} string driver | |
11374 | The driver that the passdb should use. Valid values include | |
11375 | @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and | |
11376 | @samp{static}. | |
11377 | Defaults to @samp{"pam"}. | |
11378 | @end deftypevr | |
11379 | ||
deb36188 CL |
11380 | @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args |
11381 | Space separated list of arguments to the passdb driver. | |
11382 | Defaults to @samp{""}. | |
d8c18af8 AW |
11383 | @end deftypevr |
11384 | ||
11385 | @end deftypevr | |
11386 | ||
11387 | @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs | |
11388 | List of userdb configurations, each one created by the | |
11389 | @code{userdb-configuration} constructor. | |
11390 | ||
11391 | Available @code{userdb-configuration} fields are: | |
11392 | ||
11393 | @deftypevr {@code{userdb-configuration} parameter} string driver | |
11394 | The driver that the userdb should use. Valid values include | |
11395 | @samp{passwd} and @samp{static}. | |
11396 | Defaults to @samp{"passwd"}. | |
11397 | @end deftypevr | |
11398 | ||
deb36188 CL |
11399 | @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args |
11400 | Space separated list of arguments to the userdb driver. | |
11401 | Defaults to @samp{""}. | |
d8c18af8 AW |
11402 | @end deftypevr |
11403 | ||
11404 | @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields | |
11405 | Override fields from passwd. | |
11406 | Defaults to @samp{()}. | |
11407 | @end deftypevr | |
11408 | ||
11409 | @end deftypevr | |
11410 | ||
11411 | @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration | |
11412 | Plug-in configuration, created by the @code{plugin-configuration} | |
11413 | constructor. | |
11414 | @end deftypevr | |
11415 | ||
11416 | @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces | |
11417 | List of namespaces. Each item in the list is created by the | |
11418 | @code{namespace-configuration} constructor. | |
11419 | ||
11420 | Available @code{namespace-configuration} fields are: | |
11421 | ||
11422 | @deftypevr {@code{namespace-configuration} parameter} string name | |
11423 | Name for this namespace. | |
11424 | @end deftypevr | |
11425 | ||
11426 | @deftypevr {@code{namespace-configuration} parameter} string type | |
11427 | Namespace type: @samp{private}, @samp{shared} or @samp{public}. | |
11428 | Defaults to @samp{"private"}. | |
11429 | @end deftypevr | |
11430 | ||
11431 | @deftypevr {@code{namespace-configuration} parameter} string separator | |
11432 | Hierarchy separator to use. You should use the same separator for | |
11433 | all namespaces or some clients get confused. @samp{/} is usually a good | |
11434 | one. The default however depends on the underlying mail storage | |
11435 | format. | |
11436 | Defaults to @samp{""}. | |
11437 | @end deftypevr | |
11438 | ||
11439 | @deftypevr {@code{namespace-configuration} parameter} string prefix | |
11440 | Prefix required to access this namespace. This needs to be | |
11441 | different for all namespaces. For example @samp{Public/}. | |
11442 | Defaults to @samp{""}. | |
11443 | @end deftypevr | |
11444 | ||
11445 | @deftypevr {@code{namespace-configuration} parameter} string location | |
1068f26b | 11446 | Physical location of the mailbox. This is in the same format as |
d8c18af8 AW |
11447 | mail_location, which is also the default for it. |
11448 | Defaults to @samp{""}. | |
11449 | @end deftypevr | |
11450 | ||
11451 | @deftypevr {@code{namespace-configuration} parameter} boolean inbox? | |
11452 | There can be only one INBOX, and this setting defines which | |
11453 | namespace has it. | |
11454 | Defaults to @samp{#f}. | |
11455 | @end deftypevr | |
11456 | ||
11457 | @deftypevr {@code{namespace-configuration} parameter} boolean hidden? | |
11458 | If namespace is hidden, it's not advertised to clients via NAMESPACE | |
11459 | extension. You'll most likely also want to set @samp{list? #f}. This is mostly | |
11460 | useful when converting from another server with different namespaces | |
11461 | which you want to deprecate but still keep working. For example you can | |
11462 | create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/} | |
11463 | and @samp{mail/}. | |
11464 | Defaults to @samp{#f}. | |
11465 | @end deftypevr | |
11466 | ||
11467 | @deftypevr {@code{namespace-configuration} parameter} boolean list? | |
1068f26b AE |
11468 | Show the mailboxes under this namespace with the LIST command. This |
11469 | makes the namespace visible for clients that do not support the NAMESPACE | |
d8c18af8 AW |
11470 | extension. The special @code{children} value lists child mailboxes, but |
11471 | hides the namespace prefix. | |
11472 | Defaults to @samp{#t}. | |
11473 | @end deftypevr | |
11474 | ||
11475 | @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions? | |
11476 | Namespace handles its own subscriptions. If set to @code{#f}, the | |
11477 | parent namespace handles them. The empty prefix should always have this | |
1068f26b | 11478 | as @code{#t}). |
d8c18af8 AW |
11479 | Defaults to @samp{#t}. |
11480 | @end deftypevr | |
11481 | ||
11482 | @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes | |
11483 | List of predefined mailboxes in this namespace. | |
11484 | Defaults to @samp{()}. | |
11485 | ||
11486 | Available @code{mailbox-configuration} fields are: | |
11487 | ||
11488 | @deftypevr {@code{mailbox-configuration} parameter} string name | |
11489 | Name for this mailbox. | |
11490 | @end deftypevr | |
11491 | ||
11492 | @deftypevr {@code{mailbox-configuration} parameter} string auto | |
11493 | @samp{create} will automatically create this mailbox. | |
11494 | @samp{subscribe} will both create and subscribe to the mailbox. | |
11495 | Defaults to @samp{"no"}. | |
11496 | @end deftypevr | |
11497 | ||
11498 | @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use | |
11499 | List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154. | |
11500 | Valid values are @code{\All}, @code{\Archive}, @code{\Drafts}, | |
11501 | @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}. | |
11502 | Defaults to @samp{()}. | |
11503 | @end deftypevr | |
11504 | ||
11505 | @end deftypevr | |
11506 | ||
11507 | @end deftypevr | |
11508 | ||
11509 | @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir | |
11510 | Base directory where to store runtime data. | |
11511 | Defaults to @samp{"/var/run/dovecot/"}. | |
11512 | @end deftypevr | |
11513 | ||
11514 | @deftypevr {@code{dovecot-configuration} parameter} string login-greeting | |
11515 | Greeting message for clients. | |
11516 | Defaults to @samp{"Dovecot ready."}. | |
11517 | @end deftypevr | |
11518 | ||
11519 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks | |
11520 | List of trusted network ranges. Connections from these IPs are | |
11521 | allowed to override their IP addresses and ports (for logging and for | |
11522 | authentication checks). @samp{disable-plaintext-auth} is also ignored | |
1068f26b | 11523 | for these networks. Typically you would specify your IMAP proxy servers |
d8c18af8 AW |
11524 | here. |
11525 | Defaults to @samp{()}. | |
11526 | @end deftypevr | |
11527 | ||
11528 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets | |
11529 | List of login access check sockets (e.g. tcpwrap). | |
11530 | Defaults to @samp{()}. | |
11531 | @end deftypevr | |
11532 | ||
11533 | @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle? | |
11534 | Show more verbose process titles (in ps). Currently shows user name | |
1068f26b AE |
11535 | and IP address. Useful for seeing who is actually using the IMAP |
11536 | processes (e.g. shared mailboxes or if the same uid is used for multiple | |
d8c18af8 AW |
11537 | accounts). |
11538 | Defaults to @samp{#f}. | |
11539 | @end deftypevr | |
11540 | ||
11541 | @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients? | |
11542 | Should all processes be killed when Dovecot master process shuts down. | |
11543 | Setting this to @code{#f} means that Dovecot can be upgraded without | |
11544 | forcing existing client connections to close (although that could also | |
1068f26b | 11545 | be a problem if the upgrade is e.g. due to a security fix). |
d8c18af8 AW |
11546 | Defaults to @samp{#t}. |
11547 | @end deftypevr | |
11548 | ||
11549 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count | |
11550 | If non-zero, run mail commands via this many connections to doveadm | |
11551 | server, instead of running them directly in the same process. | |
11552 | Defaults to @samp{0}. | |
11553 | @end deftypevr | |
11554 | ||
11555 | @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path | |
11556 | UNIX socket or host:port used for connecting to doveadm server. | |
11557 | Defaults to @samp{"doveadm-server"}. | |
11558 | @end deftypevr | |
11559 | ||
11560 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment | |
11561 | List of environment variables that are preserved on Dovecot startup | |
11562 | and passed down to all of its child processes. You can also give | |
11563 | key=value pairs to always set specific settings. | |
11564 | @end deftypevr | |
11565 | ||
11566 | @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth? | |
11567 | Disable LOGIN command and all other plaintext authentications unless | |
11568 | SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP | |
11569 | matches the local IP (i.e. you're connecting from the same computer), | |
11570 | the connection is considered secure and plaintext authentication is | |
11571 | allowed. See also ssl=required setting. | |
11572 | Defaults to @samp{#t}. | |
11573 | @end deftypevr | |
11574 | ||
11575 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size | |
11576 | Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled. | |
11577 | Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set | |
11578 | for caching to be used. | |
11579 | Defaults to @samp{0}. | |
11580 | @end deftypevr | |
11581 | ||
11582 | @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl | |
11583 | Time to live for cached data. After TTL expires the cached record | |
11584 | is no longer used, *except* if the main database lookup returns internal | |
11585 | failure. We also try to handle password changes automatically: If | |
11586 | user's previous authentication was successful, but this one wasn't, the | |
11587 | cache isn't used. For now this works only with plaintext | |
11588 | authentication. | |
11589 | Defaults to @samp{"1 hour"}. | |
11590 | @end deftypevr | |
11591 | ||
11592 | @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl | |
11593 | TTL for negative hits (user not found, password mismatch). | |
11594 | 0 disables caching them completely. | |
11595 | Defaults to @samp{"1 hour"}. | |
11596 | @end deftypevr | |
11597 | ||
11598 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms | |
11599 | List of realms for SASL authentication mechanisms that need them. | |
11600 | You can leave it empty if you don't want to support multiple realms. | |
11601 | Many clients simply use the first one listed here, so keep the default | |
11602 | realm first. | |
11603 | Defaults to @samp{()}. | |
11604 | @end deftypevr | |
11605 | ||
11606 | @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm | |
11607 | Default realm/domain to use if none was specified. This is used for | |
11608 | both SASL realms and appending @@domain to username in plaintext | |
11609 | logins. | |
11610 | Defaults to @samp{""}. | |
11611 | @end deftypevr | |
11612 | ||
11613 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars | |
11614 | List of allowed characters in username. If the user-given username | |
11615 | contains a character not listed in here, the login automatically fails. | |
11616 | This is just an extra check to make sure user can't exploit any | |
11617 | potential quote escaping vulnerabilities with SQL/LDAP databases. If | |
11618 | you want to allow all characters, set this value to empty. | |
11619 | Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}. | |
11620 | @end deftypevr | |
11621 | ||
11622 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation | |
11623 | Username character translations before it's looked up from | |
11624 | databases. The value contains series of from -> to characters. For | |
11625 | example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are | |
11626 | translated to @samp{@@}. | |
11627 | Defaults to @samp{""}. | |
11628 | @end deftypevr | |
11629 | ||
11630 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format | |
11631 | Username formatting before it's looked up from databases. You can | |
11632 | use the standard variables here, e.g. %Lu would lowercase the username, | |
11633 | %n would drop away the domain if it was given, or @samp{%n-AT-%d} would | |
11634 | change the @samp{@@} into @samp{-AT-}. This translation is done after | |
11635 | @samp{auth-username-translation} changes. | |
11636 | Defaults to @samp{"%Lu"}. | |
11637 | @end deftypevr | |
11638 | ||
11639 | @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator | |
11640 | If you want to allow master users to log in by specifying the master | |
11641 | username within the normal username string (i.e. not using SASL | |
11642 | mechanism's support for it), you can specify the separator character | |
11643 | here. The format is then <username><separator><master username>. | |
11644 | UW-IMAP uses @samp{*} as the separator, so that could be a good | |
11645 | choice. | |
11646 | Defaults to @samp{""}. | |
11647 | @end deftypevr | |
11648 | ||
11649 | @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username | |
11650 | Username to use for users logging in with ANONYMOUS SASL | |
11651 | mechanism. | |
11652 | Defaults to @samp{"anonymous"}. | |
11653 | @end deftypevr | |
11654 | ||
11655 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count | |
11656 | Maximum number of dovecot-auth worker processes. They're used to | |
11657 | execute blocking passdb and userdb queries (e.g. MySQL and PAM). | |
11658 | They're automatically created and destroyed as needed. | |
11659 | Defaults to @samp{30}. | |
11660 | @end deftypevr | |
11661 | ||
11662 | @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname | |
11663 | Host name to use in GSSAPI principal names. The default is to use | |
11664 | the name returned by gethostname(). Use @samp{$ALL} (with quotes) to | |
11665 | allow all keytab entries. | |
11666 | Defaults to @samp{""}. | |
11667 | @end deftypevr | |
11668 | ||
11669 | @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab | |
11670 | Kerberos keytab to use for the GSSAPI mechanism. Will use the | |
8b499030 | 11671 | system default (usually @file{/etc/krb5.keytab}) if not specified. You may |
d8c18af8 AW |
11672 | need to change the auth service to run as root to be able to read this |
11673 | file. | |
11674 | Defaults to @samp{""}. | |
11675 | @end deftypevr | |
11676 | ||
11677 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind? | |
11678 | Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon | |
11679 | and @samp{ntlm-auth} helper. | |
11680 | <doc/wiki/Authentication/Mechanisms/Winbind.txt>. | |
11681 | Defaults to @samp{#f}. | |
11682 | @end deftypevr | |
11683 | ||
11684 | @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path | |
11685 | Path for Samba's @samp{ntlm-auth} helper binary. | |
11686 | Defaults to @samp{"/usr/bin/ntlm_auth"}. | |
11687 | @end deftypevr | |
11688 | ||
11689 | @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay | |
11690 | Time to delay before replying to failed authentications. | |
11691 | Defaults to @samp{"2 secs"}. | |
11692 | @end deftypevr | |
11693 | ||
11694 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert? | |
11695 | Require a valid SSL client certificate or the authentication | |
11696 | fails. | |
11697 | Defaults to @samp{#f}. | |
11698 | @end deftypevr | |
11699 | ||
11700 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert? | |
11701 | Take the username from client's SSL certificate, using | |
11702 | @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's | |
11703 | CommonName. | |
11704 | Defaults to @samp{#f}. | |
11705 | @end deftypevr | |
11706 | ||
11707 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms | |
11708 | List of wanted authentication mechanisms. Supported mechanisms are: | |
11709 | @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5}, | |
11710 | @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi}, | |
11711 | @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also | |
11712 | @samp{disable-plaintext-auth} setting. | |
11713 | @end deftypevr | |
11714 | ||
11715 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers | |
11716 | List of IPs or hostnames to all director servers, including ourself. | |
11717 | Ports can be specified as ip:port. The default port is the same as what | |
11718 | director service's @samp{inet-listener} is using. | |
11719 | Defaults to @samp{()}. | |
11720 | @end deftypevr | |
11721 | ||
11722 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers | |
11723 | List of IPs or hostnames to all backend mail servers. Ranges are | |
11724 | allowed too, like 10.0.0.10-10.0.0.30. | |
11725 | Defaults to @samp{()}. | |
11726 | @end deftypevr | |
11727 | ||
11728 | @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire | |
11729 | How long to redirect users to a specific server after it no longer | |
11730 | has any connections. | |
11731 | Defaults to @samp{"15 min"}. | |
11732 | @end deftypevr | |
11733 | ||
11734 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer director-doveadm-port | |
11735 | TCP/IP port that accepts doveadm connections (instead of director | |
11736 | connections) If you enable this, you'll also need to add | |
11737 | @samp{inet-listener} for the port. | |
11738 | Defaults to @samp{0}. | |
11739 | @end deftypevr | |
11740 | ||
11741 | @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash | |
11742 | How the username is translated before being hashed. Useful values | |
11743 | include %Ln if user can log in with or without @@domain, %Ld if mailboxes | |
11744 | are shared within domain. | |
11745 | Defaults to @samp{"%Lu"}. | |
11746 | @end deftypevr | |
11747 | ||
11748 | @deftypevr {@code{dovecot-configuration} parameter} string log-path | |
11749 | Log file to use for error messages. @samp{syslog} logs to syslog, | |
11750 | @samp{/dev/stderr} logs to stderr. | |
11751 | Defaults to @samp{"syslog"}. | |
11752 | @end deftypevr | |
11753 | ||
11754 | @deftypevr {@code{dovecot-configuration} parameter} string info-log-path | |
11755 | Log file to use for informational messages. Defaults to | |
11756 | @samp{log-path}. | |
11757 | Defaults to @samp{""}. | |
11758 | @end deftypevr | |
11759 | ||
11760 | @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path | |
11761 | Log file to use for debug messages. Defaults to | |
11762 | @samp{info-log-path}. | |
11763 | Defaults to @samp{""}. | |
11764 | @end deftypevr | |
11765 | ||
11766 | @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility | |
11767 | Syslog facility to use if you're logging to syslog. Usually if you | |
11768 | don't want to use @samp{mail}, you'll use local0..local7. Also other | |
11769 | standard facilities are supported. | |
11770 | Defaults to @samp{"mail"}. | |
11771 | @end deftypevr | |
11772 | ||
11773 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose? | |
11774 | Log unsuccessful authentication attempts and the reasons why they | |
11775 | failed. | |
11776 | Defaults to @samp{#f}. | |
11777 | @end deftypevr | |
11778 | ||
11779 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords? | |
11780 | In case of password mismatches, log the attempted password. Valid | |
11781 | values are no, plain and sha1. sha1 can be useful for detecting brute | |
11782 | force password attempts vs. user simply trying the same password over | |
11783 | and over again. You can also truncate the value to n chars by appending | |
11784 | ":n" (e.g. sha1:6). | |
11785 | Defaults to @samp{#f}. | |
11786 | @end deftypevr | |
11787 | ||
11788 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug? | |
11789 | Even more verbose logging for debugging purposes. Shows for example | |
11790 | SQL queries. | |
11791 | Defaults to @samp{#f}. | |
11792 | @end deftypevr | |
11793 | ||
11794 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords? | |
11795 | In case of password mismatches, log the passwords and used scheme so | |
11796 | the problem can be debugged. Enabling this also enables | |
11797 | @samp{auth-debug}. | |
11798 | Defaults to @samp{#f}. | |
11799 | @end deftypevr | |
11800 | ||
11801 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug? | |
11802 | Enable mail process debugging. This can help you figure out why | |
11803 | Dovecot isn't finding your mails. | |
11804 | Defaults to @samp{#f}. | |
11805 | @end deftypevr | |
11806 | ||
11807 | @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl? | |
11808 | Show protocol level SSL errors. | |
11809 | Defaults to @samp{#f}. | |
11810 | @end deftypevr | |
11811 | ||
11812 | @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp | |
11813 | Prefix for each line written to log file. % codes are in | |
11814 | strftime(3) format. | |
11815 | Defaults to @samp{"\"%b %d %H:%M:%S \""}. | |
11816 | @end deftypevr | |
11817 | ||
11818 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements | |
11819 | List of elements we want to log. The elements which have a | |
11820 | non-empty variable value are joined together to form a comma-separated | |
11821 | string. | |
11822 | @end deftypevr | |
11823 | ||
11824 | @deftypevr {@code{dovecot-configuration} parameter} string login-log-format | |
11825 | Login log format. %s contains @samp{login-log-format-elements} | |
11826 | string, %$ contains the data we want to log. | |
11827 | Defaults to @samp{"%$: %s"}. | |
11828 | @end deftypevr | |
11829 | ||
11830 | @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix | |
11831 | Log prefix for mail processes. See doc/wiki/Variables.txt for list | |
11832 | of possible variables you can use. | |
11833 | Defaults to @samp{"\"%s(%u): \""}. | |
11834 | @end deftypevr | |
11835 | ||
11836 | @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format | |
11837 | Format to use for logging mail deliveries. You can use variables: | |
11838 | @table @code | |
11839 | @item %$ | |
11840 | Delivery status message (e.g. @samp{saved to INBOX}) | |
11841 | @item %m | |
11842 | Message-ID | |
11843 | @item %s | |
11844 | Subject | |
11845 | @item %f | |
11846 | From address | |
11847 | @item %p | |
11848 | Physical size | |
11849 | @item %w | |
11850 | Virtual size. | |
11851 | @end table | |
11852 | Defaults to @samp{"msgid=%m: %$"}. | |
11853 | @end deftypevr | |
11854 | ||
11855 | @deftypevr {@code{dovecot-configuration} parameter} string mail-location | |
11856 | Location for users' mailboxes. The default is empty, which means | |
11857 | that Dovecot tries to find the mailboxes automatically. This won't work | |
11858 | if the user doesn't yet have any mail, so you should explicitly tell | |
11859 | Dovecot the full location. | |
11860 | ||
11861 | If you're using mbox, giving a path to the INBOX | |
11862 | file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot | |
11863 | where the other mailboxes are kept. This is called the "root mail | |
11864 | directory", and it must be the first path given in the | |
11865 | @samp{mail-location} setting. | |
11866 | ||
11867 | There are a few special variables you can use, eg.: | |
11868 | ||
11869 | @table @samp | |
11870 | @item %u | |
11871 | username | |
11872 | @item %n | |
11873 | user part in user@@domain, same as %u if there's no domain | |
11874 | @item %d | |
11875 | domain part in user@@domain, empty if there's no domain | |
11876 | @item %h | |
11877 | home director | |
11878 | @end table | |
11879 | ||
11880 | See doc/wiki/Variables.txt for full list. Some examples: | |
11881 | @table @samp | |
11882 | @item maildir:~/Maildir | |
11883 | @item mbox:~/mail:INBOX=/var/mail/%u | |
11884 | @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/% | |
11885 | @end table | |
11886 | Defaults to @samp{""}. | |
11887 | @end deftypevr | |
11888 | ||
11889 | @deftypevr {@code{dovecot-configuration} parameter} string mail-uid | |
11890 | System user and group used to access mails. If you use multiple, | |
11891 | userdb can override these by returning uid or gid fields. You can use | |
11892 | either numbers or names. <doc/wiki/UserIds.txt>. | |
11893 | Defaults to @samp{""}. | |
11894 | @end deftypevr | |
11895 | ||
11896 | @deftypevr {@code{dovecot-configuration} parameter} string mail-gid | |
11897 | ||
11898 | Defaults to @samp{""}. | |
11899 | @end deftypevr | |
11900 | ||
11901 | @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group | |
11902 | Group to enable temporarily for privileged operations. Currently | |
11903 | this is used only with INBOX when either its initial creation or | |
11904 | dotlocking fails. Typically this is set to "mail" to give access to | |
11905 | /var/mail. | |
11906 | Defaults to @samp{""}. | |
11907 | @end deftypevr | |
11908 | ||
11909 | @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups | |
11910 | Grant access to these supplementary groups for mail processes. | |
11911 | Typically these are used to set up access to shared mailboxes. Note | |
11912 | that it may be dangerous to set these if users can create | |
11913 | symlinks (e.g. if "mail" group is set here, ln -s /var/mail ~/mail/var | |
11914 | could allow a user to delete others' mailboxes, or ln -s | |
11915 | /secret/shared/box ~/mail/mybox would allow reading it). | |
11916 | Defaults to @samp{""}. | |
11917 | @end deftypevr | |
11918 | ||
11919 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access? | |
8f65585b | 11920 | Allow full file system access to clients. There's no access checks |
d8c18af8 AW |
11921 | other than what the operating system does for the active UID/GID. It |
11922 | works with both maildir and mboxes, allowing you to prefix mailboxes | |
11923 | names with e.g. /path/ or ~user/. | |
11924 | Defaults to @samp{#f}. | |
11925 | @end deftypevr | |
11926 | ||
11927 | @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable? | |
11928 | Don't use mmap() at all. This is required if you store indexes to | |
8f65585b | 11929 | shared file systems (NFS or clustered file system). |
d8c18af8 AW |
11930 | Defaults to @samp{#f}. |
11931 | @end deftypevr | |
11932 | ||
11933 | @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl? | |
11934 | Rely on @samp{O_EXCL} to work when creating dotlock files. NFS | |
11935 | supports @samp{O_EXCL} since version 3, so this should be safe to use | |
11936 | nowadays by default. | |
11937 | Defaults to @samp{#t}. | |
11938 | @end deftypevr | |
11939 | ||
11940 | @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync | |
11941 | When to use fsync() or fdatasync() calls: | |
11942 | @table @code | |
11943 | @item optimized | |
11944 | Whenever necessary to avoid losing important data | |
11945 | @item always | |
11946 | Useful with e.g. NFS when write()s are delayed | |
11947 | @item never | |
11948 | Never use it (best performance, but crashes can lose data). | |
11949 | @end table | |
11950 | Defaults to @samp{"optimized"}. | |
11951 | @end deftypevr | |
11952 | ||
11953 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage? | |
11954 | Mail storage exists in NFS. Set this to yes to make Dovecot flush | |
11955 | NFS caches whenever needed. If you're using only a single mail server | |
11956 | this isn't needed. | |
11957 | Defaults to @samp{#f}. | |
11958 | @end deftypevr | |
11959 | ||
11960 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index? | |
11961 | Mail index files also exist in NFS. Setting this to yes requires | |
11962 | @samp{mmap-disable? #t} and @samp{fsync-disable? #f}. | |
11963 | Defaults to @samp{#f}. | |
11964 | @end deftypevr | |
11965 | ||
11966 | @deftypevr {@code{dovecot-configuration} parameter} string lock-method | |
11967 | Locking method for index files. Alternatives are fcntl, flock and | |
11968 | dotlock. Dotlocking uses some tricks which may create more disk I/O | |
11969 | than other locking methods. NFS users: flock doesn't work, remember to | |
11970 | change @samp{mmap-disable}. | |
11971 | Defaults to @samp{"fcntl"}. | |
11972 | @end deftypevr | |
11973 | ||
11974 | @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir | |
11975 | Directory in which LDA/LMTP temporarily stores incoming mails >128 | |
11976 | kB. | |
11977 | Defaults to @samp{"/tmp"}. | |
11978 | @end deftypevr | |
11979 | ||
11980 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid | |
11981 | Valid UID range for users. This is mostly to make sure that users can't | |
11982 | log in as daemons or other system users. Note that denying root logins is | |
11983 | hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid} | |
11984 | is set to 0. | |
11985 | Defaults to @samp{500}. | |
11986 | @end deftypevr | |
11987 | ||
11988 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid | |
11989 | ||
11990 | Defaults to @samp{0}. | |
11991 | @end deftypevr | |
11992 | ||
11993 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid | |
11994 | Valid GID range for users. Users having non-valid GID as primary group ID | |
11995 | aren't allowed to log in. If user belongs to supplementary groups with | |
11996 | non-valid GIDs, those groups are not set. | |
11997 | Defaults to @samp{1}. | |
11998 | @end deftypevr | |
11999 | ||
12000 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid | |
12001 | ||
12002 | Defaults to @samp{0}. | |
12003 | @end deftypevr | |
12004 | ||
12005 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length | |
12006 | Maximum allowed length for mail keyword name. It's only forced when | |
12007 | trying to create new keywords. | |
12008 | Defaults to @samp{50}. | |
12009 | @end deftypevr | |
12010 | ||
12011 | @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs | |
12012 | List of directories under which chrooting is allowed for mail | |
12013 | processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar | |
12014 | too). This setting doesn't affect @samp{login-chroot} | |
12015 | @samp{mail-chroot} or auth chroot settings. If this setting is empty, | |
12016 | "/./" in home dirs are ignored. WARNING: Never add directories here | |
12017 | which local users can modify, that may lead to root exploit. Usually | |
12018 | this should be done only if you don't allow shell access for users. | |
12019 | <doc/wiki/Chrooting.txt>. | |
12020 | Defaults to @samp{()}. | |
12021 | @end deftypevr | |
12022 | ||
12023 | @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot | |
12024 | Default chroot directory for mail processes. This can be overridden | |
12025 | for specific users in user database by giving /./ in user's home | |
12026 | directory (e.g. /home/./user chroots into /home). Note that usually | |
12027 | there is no real need to do chrooting, Dovecot doesn't allow users to | |
12028 | access files outside their mail directory anyway. If your home | |
12029 | directories are prefixed with the chroot directory, append "/." to | |
12030 | @samp{mail-chroot}. <doc/wiki/Chrooting.txt>. | |
12031 | Defaults to @samp{""}. | |
12032 | @end deftypevr | |
12033 | ||
12034 | @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path | |
12035 | UNIX socket path to master authentication server to find users. | |
12036 | This is used by imap (for shared users) and lda. | |
12037 | Defaults to @samp{"/var/run/dovecot/auth-userdb"}. | |
12038 | @end deftypevr | |
12039 | ||
12040 | @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir | |
12041 | Directory where to look up mail plugins. | |
12042 | Defaults to @samp{"/usr/lib/dovecot"}. | |
12043 | @end deftypevr | |
12044 | ||
12045 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins | |
12046 | List of plugins to load for all services. Plugins specific to IMAP, | |
12047 | LDA, etc. are added to this list in their own .conf files. | |
12048 | Defaults to @samp{()}. | |
12049 | @end deftypevr | |
12050 | ||
12051 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count | |
12052 | The minimum number of mails in a mailbox before updates are done to | |
12053 | cache file. This allows optimizing Dovecot's behavior to do less disk | |
12054 | writes at the cost of more disk reads. | |
12055 | Defaults to @samp{0}. | |
12056 | @end deftypevr | |
12057 | ||
12058 | @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval | |
12059 | When IDLE command is running, mailbox is checked once in a while to | |
12060 | see if there are any new mails or other changes. This setting defines | |
12061 | the minimum time to wait between those checks. Dovecot can also use | |
12062 | dnotify, inotify and kqueue to find out immediately when changes | |
12063 | occur. | |
12064 | Defaults to @samp{"30 secs"}. | |
12065 | @end deftypevr | |
12066 | ||
12067 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf? | |
12068 | Save mails with CR+LF instead of plain LF. This makes sending those | |
12069 | mails take less CPU, especially with sendfile() syscall with Linux and | |
12070 | FreeBSD. But it also creates a bit more disk I/O which may just make it | |
12071 | slower. Also note that if other software reads the mboxes/maildirs, | |
12072 | they may handle the extra CRs wrong and cause problems. | |
12073 | Defaults to @samp{#f}. | |
12074 | @end deftypevr | |
12075 | ||
12076 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs? | |
12077 | By default LIST command returns all entries in maildir beginning | |
12078 | with a dot. Enabling this option makes Dovecot return only entries | |
12079 | which are directories. This is done by stat()ing each entry, so it | |
12080 | causes more disk I/O. | |
12081 | (For systems setting struct @samp{dirent->d_type} this check is free | |
12082 | and it's done always regardless of this setting). | |
12083 | Defaults to @samp{#f}. | |
12084 | @end deftypevr | |
12085 | ||
12086 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks? | |
12087 | When copying a message, do it with hard links whenever possible. | |
12088 | This makes the performance much better, and it's unlikely to have any | |
12089 | side effects. | |
12090 | Defaults to @samp{#t}. | |
12091 | @end deftypevr | |
12092 | ||
12093 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs? | |
12094 | Assume Dovecot is the only MUA accessing Maildir: Scan cur/ | |
12095 | directory only when its mtime changes unexpectedly or when we can't find | |
12096 | the mail otherwise. | |
12097 | Defaults to @samp{#f}. | |
12098 | @end deftypevr | |
12099 | ||
12100 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks | |
12101 | Which locking methods to use for locking mbox. There are four | |
12102 | available: | |
12103 | ||
12104 | @table @code | |
12105 | @item dotlock | |
12106 | Create <mailbox>.lock file. This is the oldest and most NFS-safe | |
12107 | solution. If you want to use /var/mail/ like directory, the users will | |
12108 | need write access to that directory. | |
12109 | @item dotlock-try | |
12110 | Same as dotlock, but if it fails because of permissions or because there | |
12111 | isn't enough disk space, just skip it. | |
12112 | @item fcntl | |
12113 | Use this if possible. Works with NFS too if lockd is used. | |
12114 | @item flock | |
a01ad638 | 12115 | May not exist in all systems. Doesn't work with NFS. |
d8c18af8 AW |
12116 | @item lockf |
12117 | May not exist in all systems. Doesn't work with NFS. | |
12118 | @end table | |
12119 | ||
12120 | You can use multiple locking methods; if you do the order they're declared | |
12121 | in is important to avoid deadlocks if other MTAs/MUAs are using multiple | |
12122 | locking methods as well. Some operating systems don't allow using some of | |
12123 | them simultaneously. | |
12124 | @end deftypevr | |
12125 | ||
12126 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks | |
12127 | ||
12128 | @end deftypevr | |
12129 | ||
12130 | @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout | |
12131 | Maximum time to wait for lock (all of them) before aborting. | |
12132 | Defaults to @samp{"5 mins"}. | |
12133 | @end deftypevr | |
12134 | ||
12135 | @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout | |
12136 | If dotlock exists but the mailbox isn't modified in any way, | |
12137 | override the lock file after this much time. | |
12138 | Defaults to @samp{"2 mins"}. | |
12139 | @end deftypevr | |
12140 | ||
12141 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs? | |
12142 | When mbox changes unexpectedly we have to fully read it to find out | |
12143 | what changed. If the mbox is large this can take a long time. Since | |
12144 | the change is usually just a newly appended mail, it'd be faster to | |
12145 | simply read the new mails. If this setting is enabled, Dovecot does | |
12146 | this but still safely fallbacks to re-reading the whole mbox file | |
12147 | whenever something in mbox isn't how it's expected to be. The only real | |
12148 | downside to this setting is that if some other MUA changes message | |
12149 | flags, Dovecot doesn't notice it immediately. Note that a full sync is | |
12150 | done with SELECT, EXAMINE, EXPUNGE and CHECK commands. | |
12151 | Defaults to @samp{#t}. | |
12152 | @end deftypevr | |
12153 | ||
12154 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs? | |
12155 | Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT, | |
12156 | EXAMINE, EXPUNGE or CHECK commands. If this is set, | |
12157 | @samp{mbox-dirty-syncs} is ignored. | |
12158 | Defaults to @samp{#f}. | |
12159 | @end deftypevr | |
12160 | ||
12161 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes? | |
12162 | Delay writing mbox headers until doing a full write sync (EXPUNGE | |
12163 | and CHECK commands and when closing the mailbox). This is especially | |
12164 | useful for POP3 where clients often delete all mails. The downside is | |
12165 | that our changes aren't immediately visible to other MUAs. | |
12166 | Defaults to @samp{#t}. | |
12167 | @end deftypevr | |
12168 | ||
12169 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size | |
12170 | If mbox size is smaller than this (e.g. 100k), don't write index | |
12171 | files. If an index file already exists it's still read, just not | |
12172 | updated. | |
12173 | Defaults to @samp{0}. | |
12174 | @end deftypevr | |
12175 | ||
12176 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size | |
12177 | Maximum dbox file size until it's rotated. | |
12178 | Defaults to @samp{2000000}. | |
12179 | @end deftypevr | |
12180 | ||
12181 | @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval | |
12182 | Maximum dbox file age until it's rotated. Typically in days. Day | |
12183 | begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check | |
12184 | disabled. | |
12185 | Defaults to @samp{"1d"}. | |
12186 | @end deftypevr | |
12187 | ||
12188 | @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space? | |
12189 | When creating new mdbox files, immediately preallocate their size to | |
12190 | @samp{mdbox-rotate-size}. This setting currently works only in Linux | |
8f65585b | 12191 | with some file systems (ext4, xfs). |
d8c18af8 AW |
12192 | Defaults to @samp{#f}. |
12193 | @end deftypevr | |
12194 | ||
12195 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir | |
12196 | sdbox and mdbox support saving mail attachments to external files, | |
12197 | which also allows single instance storage for them. Other backends | |
12198 | don't support this for now. | |
12199 | ||
12200 | WARNING: This feature hasn't been tested much yet. Use at your own risk. | |
12201 | ||
12202 | Directory root where to store mail attachments. Disabled, if empty. | |
12203 | Defaults to @samp{""}. | |
12204 | @end deftypevr | |
12205 | ||
12206 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size | |
12207 | Attachments smaller than this aren't saved externally. It's also | |
12208 | possible to write a plugin to disable saving specific attachments | |
12209 | externally. | |
12210 | Defaults to @samp{128000}. | |
12211 | @end deftypevr | |
12212 | ||
12213 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs | |
8f65585b | 12214 | File system backend to use for saving attachments: |
d8c18af8 AW |
12215 | @table @code |
12216 | @item posix | |
12217 | No SiS done by Dovecot (but this might help FS's own deduplication) | |
12218 | @item sis posix | |
12219 | SiS with immediate byte-by-byte comparison during saving | |
12220 | @item sis-queue posix | |
12221 | SiS with delayed comparison and deduplication. | |
12222 | @end table | |
12223 | Defaults to @samp{"sis posix"}. | |
12224 | @end deftypevr | |
12225 | ||
12226 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash | |
12227 | Hash format to use in attachment filenames. You can add any text and | |
12228 | variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}}, | |
12229 | @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be | |
12230 | truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits. | |
12231 | Defaults to @samp{"%@{sha1@}"}. | |
12232 | @end deftypevr | |
12233 | ||
12234 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit | |
12235 | ||
12236 | Defaults to @samp{100}. | |
12237 | @end deftypevr | |
12238 | ||
12239 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit | |
12240 | ||
12241 | Defaults to @samp{1000}. | |
12242 | @end deftypevr | |
12243 | ||
12244 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit | |
12245 | Default VSZ (virtual memory size) limit for service processes. | |
12246 | This is mainly intended to catch and kill processes that leak memory | |
12247 | before they eat up everything. | |
12248 | Defaults to @samp{256000000}. | |
12249 | @end deftypevr | |
12250 | ||
12251 | @deftypevr {@code{dovecot-configuration} parameter} string default-login-user | |
12252 | Login user is internally used by login processes. This is the most | |
12253 | untrusted user in Dovecot system. It shouldn't have access to anything | |
12254 | at all. | |
12255 | Defaults to @samp{"dovenull"}. | |
12256 | @end deftypevr | |
12257 | ||
12258 | @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user | |
12259 | Internal user is used by unprivileged processes. It should be | |
12260 | separate from login user, so that login processes can't disturb other | |
12261 | processes. | |
12262 | Defaults to @samp{"dovecot"}. | |
12263 | @end deftypevr | |
12264 | ||
12265 | @deftypevr {@code{dovecot-configuration} parameter} string ssl? | |
12266 | SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>. | |
12267 | Defaults to @samp{"required"}. | |
12268 | @end deftypevr | |
12269 | ||
12270 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert | |
12271 | PEM encoded X.509 SSL/TLS certificate (public key). | |
12272 | Defaults to @samp{"</etc/dovecot/default.pem"}. | |
12273 | @end deftypevr | |
12274 | ||
12275 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-key | |
12276 | PEM encoded SSL/TLS private key. The key is opened before | |
12277 | dropping root privileges, so keep the key file unreadable by anyone but | |
12278 | root. | |
12279 | Defaults to @samp{"</etc/dovecot/private/default.pem"}. | |
12280 | @end deftypevr | |
12281 | ||
12282 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password | |
12283 | If key file is password protected, give the password here. | |
12284 | Alternatively give it when starting dovecot with -p parameter. Since | |
12285 | this file is often world-readable, you may want to place this setting | |
12286 | instead to a different. | |
12287 | Defaults to @samp{""}. | |
12288 | @end deftypevr | |
12289 | ||
12290 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca | |
12291 | PEM encoded trusted certificate authority. Set this only if you | |
12292 | intend to use @samp{ssl-verify-client-cert? #t}. The file should | |
12293 | contain the CA certificate(s) followed by the matching | |
12294 | CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}). | |
12295 | Defaults to @samp{""}. | |
12296 | @end deftypevr | |
12297 | ||
12298 | @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl? | |
12299 | Require that CRL check succeeds for client certificates. | |
12300 | Defaults to @samp{#t}. | |
12301 | @end deftypevr | |
12302 | ||
12303 | @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert? | |
12304 | Request client to send a certificate. If you also want to require | |
12305 | it, set @samp{auth-ssl-require-client-cert? #t} in auth section. | |
12306 | Defaults to @samp{#f}. | |
12307 | @end deftypevr | |
12308 | ||
12309 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field | |
12310 | Which field from certificate to use for username. commonName and | |
12311 | x500UniqueIdentifier are the usual choices. You'll also need to set | |
12312 | @samp{auth-ssl-username-from-cert? #t}. | |
12313 | Defaults to @samp{"commonName"}. | |
12314 | @end deftypevr | |
12315 | ||
12316 | @deftypevr {@code{dovecot-configuration} parameter} hours ssl-parameters-regenerate | |
12317 | How often to regenerate the SSL parameters file. Generation is | |
12318 | quite CPU intensive operation. The value is in hours, 0 disables | |
12319 | regeneration entirely. | |
12320 | Defaults to @samp{168}. | |
12321 | @end deftypevr | |
12322 | ||
12323 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-protocols | |
12324 | SSL protocols to use. | |
12325 | Defaults to @samp{"!SSLv2"}. | |
12326 | @end deftypevr | |
12327 | ||
12328 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list | |
12329 | SSL ciphers to use. | |
12330 | Defaults to @samp{"ALL:!LOW:!SSLv2:!EXP:!aNULL"}. | |
12331 | @end deftypevr | |
12332 | ||
12333 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device | |
12334 | SSL crypto device to use, for valid values run "openssl engine". | |
12335 | Defaults to @samp{""}. | |
12336 | @end deftypevr | |
12337 | ||
12338 | @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address | |
12339 | Address to use when sending rejection mails. | |
66329c23 AW |
12340 | %d expands to recipient domain. |
12341 | Defaults to @samp{"postmaster@@%d"}. | |
d8c18af8 AW |
12342 | @end deftypevr |
12343 | ||
12344 | @deftypevr {@code{dovecot-configuration} parameter} string hostname | |
12345 | Hostname to use in various parts of sent mails (e.g. in Message-Id) | |
12346 | and in LMTP replies. Default is the system's real hostname@@domain. | |
12347 | Defaults to @samp{""}. | |
12348 | @end deftypevr | |
12349 | ||
12350 | @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail? | |
12351 | If user is over quota, return with temporary failure instead of | |
12352 | bouncing the mail. | |
12353 | Defaults to @samp{#f}. | |
12354 | @end deftypevr | |
12355 | ||
12356 | @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path | |
12357 | Binary to use for sending mails. | |
12358 | Defaults to @samp{"/usr/sbin/sendmail"}. | |
12359 | @end deftypevr | |
12360 | ||
12361 | @deftypevr {@code{dovecot-configuration} parameter} string submission-host | |
12362 | If non-empty, send mails via this SMTP host[:port] instead of | |
12363 | sendmail. | |
12364 | Defaults to @samp{""}. | |
12365 | @end deftypevr | |
12366 | ||
12367 | @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject | |
12368 | Subject: header to use for rejection mails. You can use the same | |
12369 | variables as for @samp{rejection-reason} below. | |
12370 | Defaults to @samp{"Rejected: %s"}. | |
12371 | @end deftypevr | |
12372 | ||
12373 | @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason | |
12374 | Human readable error message for rejection mails. You can use | |
12375 | variables: | |
12376 | ||
12377 | @table @code | |
12378 | @item %n | |
12379 | CRLF | |
12380 | @item %r | |
12381 | reason | |
12382 | @item %s | |
12383 | original subject | |
12384 | @item %t | |
12385 | recipient | |
12386 | @end table | |
12387 | Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}. | |
12388 | @end deftypevr | |
12389 | ||
12390 | @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter | |
12391 | Delimiter character between local-part and detail in email | |
12392 | address. | |
12393 | Defaults to @samp{"+"}. | |
12394 | @end deftypevr | |
12395 | ||
12396 | @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header | |
12397 | Header where the original recipient address (SMTP's RCPT TO: | |
12398 | address) is taken from if not available elsewhere. With dovecot-lda -a | |
12399 | parameter overrides this. A commonly used header for this is | |
12400 | X-Original-To. | |
12401 | Defaults to @samp{""}. | |
12402 | @end deftypevr | |
12403 | ||
12404 | @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate? | |
12405 | Should saving a mail to a nonexistent mailbox automatically create | |
12406 | it?. | |
12407 | Defaults to @samp{#f}. | |
12408 | @end deftypevr | |
12409 | ||
12410 | @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe? | |
12411 | Should automatically created mailboxes be also automatically | |
12412 | subscribed?. | |
12413 | Defaults to @samp{#f}. | |
12414 | @end deftypevr | |
12415 | ||
12416 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length | |
12417 | Maximum IMAP command line length. Some clients generate very long | |
12418 | command lines with huge mailboxes, so you may need to raise this if you | |
12419 | get "Too long argument" or "IMAP command line too large" errors | |
12420 | often. | |
12421 | Defaults to @samp{64000}. | |
12422 | @end deftypevr | |
12423 | ||
12424 | @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format | |
12425 | IMAP logout format string: | |
12426 | @table @code | |
12427 | @item %i | |
12428 | total number of bytes read from client | |
12429 | @item %o | |
12430 | total number of bytes sent to client. | |
12431 | @end table | |
12432 | Defaults to @samp{"in=%i out=%o"}. | |
12433 | @end deftypevr | |
12434 | ||
12435 | @deftypevr {@code{dovecot-configuration} parameter} string imap-capability | |
12436 | Override the IMAP CAPABILITY response. If the value begins with '+', | |
12437 | add the given capabilities on top of the defaults (e.g. +XFOO XBAR). | |
12438 | Defaults to @samp{""}. | |
12439 | @end deftypevr | |
12440 | ||
12441 | @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval | |
12442 | How long to wait between "OK Still here" notifications when client | |
12443 | is IDLEing. | |
12444 | Defaults to @samp{"2 mins"}. | |
12445 | @end deftypevr | |
12446 | ||
12447 | @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send | |
12448 | ID field names and values to send to clients. Using * as the value | |
12449 | makes Dovecot use the default value. The following fields have default | |
12450 | values currently: name, version, os, os-version, support-url, | |
12451 | support-email. | |
12452 | Defaults to @samp{""}. | |
12453 | @end deftypevr | |
12454 | ||
12455 | @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log | |
12456 | ID fields sent by client to log. * means everything. | |
12457 | Defaults to @samp{""}. | |
12458 | @end deftypevr | |
12459 | ||
12460 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds | |
12461 | Workarounds for various client bugs: | |
12462 | ||
12463 | @table @code | |
12464 | @item delay-newmail | |
12465 | Send EXISTS/RECENT new mail notifications only when replying to NOOP and | |
12466 | CHECK commands. Some clients ignore them otherwise, for example OSX | |
12467 | Mail (<v2.1). Outlook Express breaks more badly though, without this it | |
12468 | may show user "Message no longer in server" errors. Note that OE6 | |
12469 | still breaks even with this workaround if synchronization is set to | |
12470 | "Headers Only". | |
12471 | ||
12472 | @item tb-extra-mailbox-sep | |
12473 | Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and | |
12474 | adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to | |
12475 | ignore the extra @samp{/} instead of treating it as invalid mailbox name. | |
12476 | ||
12477 | @item tb-lsub-flags | |
12478 | Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox). | |
12479 | This makes Thunderbird realize they aren't selectable and show them | |
12480 | greyed out, instead of only later giving "not selectable" popup error. | |
12481 | @end table | |
12482 | Defaults to @samp{()}. | |
12483 | @end deftypevr | |
12484 | ||
12485 | @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host | |
12486 | Host allowed in URLAUTH URLs sent by client. "*" allows all. | |
12487 | Defaults to @samp{""}. | |
12488 | @end deftypevr | |
12489 | ||
12490 | ||
12491 | Whew! Lots of configuration options. The nice thing about it though is | |
12492 | that GuixSD has a complete interface to Dovecot's configuration | |
12493 | language. This allows not only a nice way to declare configurations, | |
12494 | but also offers reflective capabilities as well: users can write code to | |
12495 | inspect and transform configurations from within Scheme. | |
12496 | ||
12497 | However, it could be that you just want to get a @code{dovecot.conf} up | |
12498 | and running. In that case, you can pass an | |
7414de0a | 12499 | @code{opaque-dovecot-configuration} as the @code{#:config} parameter to |
d8c18af8 AW |
12500 | @code{dovecot-service}. As its name indicates, an opaque configuration |
12501 | does not have easy reflective capabilities. | |
12502 | ||
12503 | Available @code{opaque-dovecot-configuration} fields are: | |
12504 | ||
12505 | @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot | |
12506 | The dovecot package. | |
12507 | @end deftypevr | |
12508 | ||
12509 | @deftypevr {@code{opaque-dovecot-configuration} parameter} string string | |
12510 | The contents of the @code{dovecot.conf}, as a string. | |
12511 | @end deftypevr | |
12512 | ||
12513 | For example, if your @code{dovecot.conf} is just the empty string, you | |
12514 | could instantiate a dovecot service like this: | |
12515 | ||
12516 | @example | |
12517 | (dovecot-service #:config | |
12518 | (opaque-dovecot-configuration | |
12519 | (string ""))) | |
12520 | @end example | |
12521 | ||
f88371e8 SB |
12522 | @subsubheading OpenSMTPD Service |
12523 | ||
12524 | @deffn {Scheme Variable} opensmtpd-service-type | |
12525 | This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD} | |
12526 | service, whose value should be an @code{opensmtpd-configuration} object | |
12527 | as in this example: | |
12528 | ||
12529 | @example | |
12530 | (service opensmtpd-service-type | |
12531 | (opensmtpd-configuration | |
12532 | (config-file (local-file "./my-smtpd.conf")))) | |
12533 | @end example | |
12534 | @end deffn | |
12535 | ||
12536 | @deftp {Data Type} opensmtpd-configuration | |
9fc221b5 | 12537 | Data type representing the configuration of opensmtpd. |
f88371e8 SB |
12538 | |
12539 | @table @asis | |
12540 | @item @code{package} (default: @var{opensmtpd}) | |
12541 | Package object of the OpenSMTPD SMTP server. | |
12542 | ||
12543 | @item @code{config-file} (default: @var{%default-opensmtpd-file}) | |
12544 | File-like object of the OpenSMTPD configuration file to use. By default | |
12545 | it listens on the loopback network interface, and allows for mail from | |
12546 | users and daemons on the local machine, as well as permitting email to | |
12547 | remote servers. Run @command{man smtpd.conf} for more information. | |
12548 | ||
12549 | @end table | |
12550 | @end deftp | |
859e367d | 12551 | |
82ccc499 CZ |
12552 | @subsubheading Exim Service |
12553 | ||
12554 | @deffn {Scheme Variable} exim-service-type | |
12555 | This is the type of the @uref{https://exim.org, Exim} service, whose value | |
12556 | should be an @code{exim-configuration} object as in this example: | |
12557 | ||
12558 | @example | |
12559 | (service exim-service-type | |
12560 | (exim-configuration | |
12561 | (config-file (local-file "./my-exim.conf")) | |
12562 | (aliases '(("postmaster" "bob") | |
12563 | ("bob" "bob@@example.com" "bob@@example2.com"))))) | |
12564 | @end example | |
12565 | @end deffn | |
12566 | ||
12567 | @deftp {Data Type} exim-configuration | |
12568 | Data type representing the configuration of exim. | |
12569 | ||
12570 | @table @asis | |
12571 | @item @code{package} (default: @var{exim}) | |
12572 | Package object of the Exim server. | |
12573 | ||
12574 | @item @code{config-file} (default: @code{#f}) | |
12575 | File-like object of the Exim configuration file to use. If its value is | |
12576 | @code{#f} then use the default configuration file from the package | |
12577 | provided in @code{package}. The resulting configuration file is loaded | |
12578 | after setting the @code{exim_user} and @code{exim_group} configuration | |
12579 | variables. | |
12580 | ||
12581 | @item @code{aliases} (default: @code{'()}) | |
12582 | List of aliases to use when delivering mail on this system. The | |
12583 | @code{car} of each list is used to match incoming mail, with the | |
12584 | @code{cdr} of each list designating how to deliver it. There may be many | |
12585 | delivery methods provided, in which case the mail is delivered to them | |
12586 | all. | |
12587 | ||
12588 | @end table | |
12589 | @end deftp | |
12590 | ||
78cef99b CL |
12591 | @node Messaging Services |
12592 | @subsubsection Messaging Services | |
12593 | ||
12594 | @cindex messaging | |
12595 | @cindex jabber | |
12596 | @cindex XMPP | |
12597 | The @code{(gnu services messaging)} module provides Guix service | |
12598 | definitions for messaging services: currently only Prosody is supported. | |
12599 | ||
12600 | @subsubheading Prosody Service | |
12601 | ||
12602 | @deffn {Scheme Variable} prosody-service-type | |
12603 | This is the type for the @uref{http://prosody.im, Prosody XMPP | |
12604 | communication server}. Its value must be a @code{prosody-configuration} | |
12605 | record as in this example: | |
12606 | ||
12607 | @example | |
12608 | (service prosody-service-type | |
12609 | (prosody-configuration | |
12610 | (modules-enabled (cons "groups" %default-modules-enabled)) | |
12611 | (int-components | |
12612 | (list | |
12613 | (int-component-configuration | |
12614 | (hostname "conference.example.net") | |
12615 | (plugin "muc") | |
12616 | (mod-muc (mod-muc-configuration))))) | |
12617 | (virtualhosts | |
12618 | (list | |
12619 | (virtualhost-configuration | |
12620 | (domain "example.net")))))) | |
12621 | @end example | |
12622 | ||
12623 | See below for details about @code{prosody-configuration}. | |
12624 | ||
12625 | @end deffn | |
12626 | ||
12627 | By default, Prosody does not need much configuration. Only one | |
12628 | @code{virtualhosts} field is needed: it specifies the domain you wish | |
12629 | Prosody to serve. | |
12630 | ||
12631 | Prosodyctl will help you generate X.509 certificates and keys: | |
12632 | ||
12633 | @example | |
12634 | prosodyctl cert request example.net | |
12635 | @end example | |
12636 | ||
12637 | The available configuration parameters follow. Each parameter | |
12638 | definition is preceded by its type; for example, @samp{string-list foo} | |
12639 | indicates that the @code{foo} parameter should be specified as a list of | |
12640 | strings. Types starting with @code{maybe-} denote parameters that won't | |
12641 | show up in @code{prosody.cfg.lua} when their value is @code{'disabled}. | |
12642 | ||
12643 | There is also a way to specify the configuration as a string, if you | |
12644 | have an old @code{prosody.cfg.lua} file that you want to port over from | |
12645 | some other system; see the end for more details. | |
12646 | ||
12647 | @c The following documentation was initially generated by | |
12648 | @c (generate-documentation) in (gnu services messaging). Manually maintained | |
12649 | @c documentation is better, so we shouldn't hesitate to edit below as | |
12650 | @c needed. However if the change you want to make to this documentation | |
12651 | @c can be done in an automated way, it's probably easier to change | |
12652 | @c (generate-documentation) than to make it below and have to deal with | |
12653 | @c the churn as Prosody updates. | |
12654 | ||
12655 | Available @code{prosody-configuration} fields are: | |
12656 | ||
12657 | @deftypevr {@code{prosody-configuration} parameter} package prosody | |
12658 | The Prosody package. | |
12659 | @end deftypevr | |
12660 | ||
12661 | @deftypevr {@code{prosody-configuration} parameter} file-name data-path | |
12662 | Location of the Prosody data storage directory. See | |
12663 | @url{http://prosody.im/doc/configure}. | |
12664 | Defaults to @samp{"/var/lib/prosody"}. | |
12665 | @end deftypevr | |
12666 | ||
12667 | @deftypevr {@code{prosody-configuration} parameter} file-name-list plugin-paths | |
12668 | Additional plugin directories. They are searched in all the specified | |
12669 | paths in order. See @url{http://prosody.im/doc/plugins_directory}. | |
12670 | Defaults to @samp{()}. | |
12671 | @end deftypevr | |
12672 | ||
12673 | @deftypevr {@code{prosody-configuration} parameter} string-list admins | |
12674 | This is a list of accounts that are admins for the server. Note that you | |
12675 | must create the accounts separately. See @url{http://prosody.im/doc/admins} and | |
12676 | @url{http://prosody.im/doc/creating_accounts}. | |
12677 | Example: @code{(admins '("user1@@example.com" "user2@@example.net"))} | |
12678 | Defaults to @samp{()}. | |
12679 | @end deftypevr | |
12680 | ||
12681 | @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent? | |
12682 | Enable use of libevent for better performance under high load. See | |
12683 | @url{http://prosody.im/doc/libevent}. | |
12684 | Defaults to @samp{#f}. | |
12685 | @end deftypevr | |
12686 | ||
12687 | @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled | |
12688 | This is the list of modules Prosody will load on startup. It looks for | |
12689 | @code{mod_modulename.lua} in the plugins folder, so make sure that exists too. | |
12690 | Documentation on modules can be found at: @url{http://prosody.im/doc/modules}. | |
12691 | Defaults to @samp{%default-modules-enabled}. | |
12692 | @end deftypevr | |
12693 | ||
12694 | @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled | |
12695 | @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but | |
12696 | should you want to disable them then add them to this list. | |
12697 | Defaults to @samp{()}. | |
12698 | @end deftypevr | |
12699 | ||
12700 | @deftypevr {@code{prosody-configuration} parameter} file-name groups-file | |
12701 | Path to a text file where the shared groups are defined. If this path is | |
12702 | empty then @samp{mod_groups} does nothing. See | |
12703 | @url{http://prosody.im/doc/modules/mod_groups}. | |
12704 | Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}. | |
12705 | @end deftypevr | |
12706 | ||
12707 | @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration? | |
12708 | Disable account creation by default, for security. See | |
12709 | @url{http://prosody.im/doc/creating_accounts}. | |
12710 | Defaults to @samp{#f}. | |
12711 | @end deftypevr | |
12712 | ||
12713 | @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl | |
12714 | These are the SSL/TLS-related settings. Most of them are disabled so to | |
12715 | use Prosody's defaults. If you do not completely understand these options, do | |
12716 | not add them to your config, it is easy to lower the security of your server | |
12717 | using them. See @url{http://prosody.im/doc/advanced_ssl_config}. | |
12718 | ||
12719 | Available @code{ssl-configuration} fields are: | |
12720 | ||
12721 | @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol | |
12722 | This determines what handshake to use. | |
12723 | @end deftypevr | |
12724 | ||
12725 | @deftypevr {@code{ssl-configuration} parameter} file-name key | |
12726 | Path to your private key file, relative to @code{/etc/prosody}. | |
12727 | Defaults to @samp{"/etc/prosody/certs/key.pem"}. | |
12728 | @end deftypevr | |
12729 | ||
12730 | @deftypevr {@code{ssl-configuration} parameter} file-name certificate | |
12731 | Path to your certificate file, relative to @code{/etc/prosody}. | |
12732 | Defaults to @samp{"/etc/prosody/certs/cert.pem"}. | |
12733 | @end deftypevr | |
12734 | ||
12735 | @deftypevr {@code{ssl-configuration} parameter} file-name capath | |
12736 | Path to directory containing root certificates that you wish Prosody to | |
12737 | trust when verifying the certificates of remote servers. | |
12738 | Defaults to @samp{"/etc/ssl/certs"}. | |
12739 | @end deftypevr | |
12740 | ||
12741 | @deftypevr {@code{ssl-configuration} parameter} maybe-file-name cafile | |
12742 | Path to a file containing root certificates that you wish Prosody to trust. | |
12743 | Similar to @code{capath} but with all certificates concatenated together. | |
12744 | @end deftypevr | |
12745 | ||
12746 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify | |
12747 | A list of verification options (these mostly map to OpenSSL's | |
12748 | @code{set_verify()} flags). | |
12749 | @end deftypevr | |
12750 | ||
12751 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options | |
12752 | A list of general options relating to SSL/TLS. These map to OpenSSL's | |
12753 | @code{set_options()}. For a full list of options available in LuaSec, see the | |
12754 | LuaSec source. | |
12755 | @end deftypevr | |
12756 | ||
12757 | @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth | |
12758 | How long a chain of certificate authorities to check when looking for a | |
12759 | trusted root certificate. | |
12760 | @end deftypevr | |
12761 | ||
12762 | @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers | |
12763 | An OpenSSL cipher string. This selects what ciphers Prosody will offer to | |
12764 | clients, and in what order. | |
12765 | @end deftypevr | |
12766 | ||
12767 | @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam | |
12768 | A path to a file containing parameters for Diffie-Hellman key exchange. You | |
12769 | can create such a file with: | |
12770 | @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048} | |
12771 | @end deftypevr | |
12772 | ||
12773 | @deftypevr {@code{ssl-configuration} parameter} maybe-string curve | |
12774 | Curve for Elliptic curve Diffie-Hellman. Prosody's default is | |
12775 | @samp{"secp384r1"}. | |
12776 | @end deftypevr | |
12777 | ||
12778 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext | |
12779 | A list of "extra" verification options. | |
12780 | @end deftypevr | |
12781 | ||
12782 | @deftypevr {@code{ssl-configuration} parameter} maybe-string password | |
12783 | Password for encrypted private keys. | |
12784 | @end deftypevr | |
12785 | ||
12786 | @end deftypevr | |
12787 | ||
12788 | @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption? | |
12789 | Whether to force all client-to-server connections to be encrypted or not. | |
12790 | See @url{http://prosody.im/doc/modules/mod_tls}. | |
12791 | Defaults to @samp{#f}. | |
12792 | @end deftypevr | |
12793 | ||
12794 | @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption? | |
12795 | Whether to force all server-to-server connections to be encrypted or not. | |
12796 | See @url{http://prosody.im/doc/modules/mod_tls}. | |
12797 | Defaults to @samp{#f}. | |
12798 | @end deftypevr | |
12799 | ||
12800 | @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth? | |
12801 | Whether to require encryption and certificate authentication. This | |
12802 | provides ideal security, but requires servers you communicate with to support | |
12803 | encryption AND present valid, trusted certificates. See | |
12804 | @url{http://prosody.im/doc/s2s#security}. | |
12805 | Defaults to @samp{#f}. | |
12806 | @end deftypevr | |
12807 | ||
12808 | @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains | |
12809 | Many servers don't support encryption or have invalid or self-signed | |
12810 | certificates. You can list domains here that will not be required to | |
12811 | authenticate using certificates. They will be authenticated using DNS. See | |
12812 | @url{http://prosody.im/doc/s2s#security}. | |
12813 | Defaults to @samp{()}. | |
12814 | @end deftypevr | |
12815 | ||
12816 | @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains | |
12817 | Even if you leave @code{s2s-secure-auth?} disabled, you can still require | |
12818 | valid certificates for some domains by specifying a list here. See | |
12819 | @url{http://prosody.im/doc/s2s#security}. | |
12820 | Defaults to @samp{()}. | |
12821 | @end deftypevr | |
12822 | ||
12823 | @deftypevr {@code{prosody-configuration} parameter} string authentication | |
12824 | Select the authentication backend to use. The default provider stores | |
12825 | passwords in plaintext and uses Prosody's configured data storage to store the | |
12826 | authentication data. If you do not trust your server please see | |
12827 | @url{http://prosody.im/doc/modules/mod_auth_internal_hashed} for information | |
12828 | about using the hashed backend. See also | |
12829 | @url{http://prosody.im/doc/authentication} | |
12830 | Defaults to @samp{"internal_plain"}. | |
12831 | @end deftypevr | |
12832 | ||
12833 | @deftypevr {@code{prosody-configuration} parameter} maybe-string log | |
12834 | Set logging options. Advanced logging configuration is not yet supported | |
12835 | by the GuixSD Prosody Service. See @url{http://prosody.im/doc/logging}. | |
12836 | Defaults to @samp{"*syslog"}. | |
12837 | @end deftypevr | |
12838 | ||
12839 | @deftypevr {@code{prosody-configuration} parameter} file-name pidfile | |
12840 | File to write pid in. See @url{http://prosody.im/doc/modules/mod_posix}. | |
12841 | Defaults to @samp{"/var/run/prosody/prosody.pid"}. | |
12842 | @end deftypevr | |
12843 | ||
12844 | @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts | |
12845 | A host in Prosody is a domain on which user accounts can be created. For | |
12846 | example if you want your users to have addresses like | |
12847 | @samp{"john.smith@@example.com"} then you need to add a host | |
12848 | @samp{"example.com"}. All options in this list will apply only to this host. | |
12849 | ||
12850 | Note: the name "virtual" host is used in configuration to avoid confusion with | |
12851 | the actual physical host that Prosody is installed on. A single Prosody | |
12852 | instance can serve many domains, each one defined as a VirtualHost entry in | |
12853 | Prosody's configuration. Conversely a server that hosts a single domain would | |
12854 | have just one VirtualHost entry. | |
12855 | ||
12856 | See @url{http://prosody.im/doc/configure#virtual_host_settings}. | |
12857 | ||
12858 | Available @code{virtualhost-configuration} fields are: | |
12859 | ||
12860 | 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: | |
12861 | @deftypevr {@code{virtualhost-configuration} parameter} string domain | |
12862 | Domain you wish Prosody to serve. | |
12863 | @end deftypevr | |
12864 | ||
12865 | @end deftypevr | |
12866 | ||
12867 | @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components | |
12868 | Components are extra services on a server which are available to clients, | |
12869 | usually on a subdomain of the main server (such as | |
12870 | @samp{"mycomponent.example.com"}). Example components might be chatroom | |
12871 | servers, user directories, or gateways to other protocols. | |
12872 | ||
12873 | Internal components are implemented with Prosody-specific plugins. To add an | |
12874 | internal component, you simply fill the hostname field, and the plugin you wish | |
12875 | to use for the component. | |
12876 | ||
12877 | See @url{http://prosody.im/doc/components}. | |
12878 | Defaults to @samp{()}. | |
12879 | ||
12880 | Available @code{int-component-configuration} fields are: | |
12881 | ||
12882 | 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: | |
12883 | @deftypevr {@code{int-component-configuration} parameter} string hostname | |
12884 | Hostname of the component. | |
12885 | @end deftypevr | |
12886 | ||
12887 | @deftypevr {@code{int-component-configuration} parameter} string plugin | |
12888 | Plugin you wish to use for the component. | |
12889 | @end deftypevr | |
12890 | ||
12891 | @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc | |
12892 | Multi-user chat (MUC) is Prosody's module for allowing you to create | |
12893 | hosted chatrooms/conferences for XMPP users. | |
12894 | ||
12895 | General information on setting up and using multi-user chatrooms can be found | |
12896 | in the "Chatrooms" documentation (@url{http://prosody.im/doc/chatrooms}), | |
12897 | which you should read if you are new to XMPP chatrooms. | |
12898 | ||
12899 | See also @url{http://prosody.im/doc/modules/mod_muc}. | |
12900 | ||
12901 | Available @code{mod-muc-configuration} fields are: | |
12902 | ||
12903 | @deftypevr {@code{mod-muc-configuration} parameter} string name | |
12904 | The name to return in service discovery responses. | |
12905 | Defaults to @samp{"Prosody Chatrooms"}. | |
12906 | @end deftypevr | |
12907 | ||
12908 | @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation | |
12909 | If @samp{#t}, this will only allow admins to create new chatrooms. | |
12910 | Otherwise anyone can create a room. The value @samp{"local"} restricts room | |
12911 | creation to users on the service's parent domain. E.g. @samp{user@@example.com} | |
12912 | can create rooms on @samp{rooms.example.com}. The value @samp{"admin"} | |
12913 | restricts to service administrators only. | |
12914 | Defaults to @samp{#f}. | |
12915 | @end deftypevr | |
12916 | ||
12917 | @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages | |
12918 | Maximum number of history messages that will be sent to the member that has | |
12919 | just joined the room. | |
12920 | Defaults to @samp{20}. | |
12921 | @end deftypevr | |
12922 | ||
12923 | @end deftypevr | |
12924 | ||
12925 | @end deftypevr | |
12926 | ||
12927 | @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components | |
12928 | External components use XEP-0114, which most standalone components | |
12929 | support. To add an external component, you simply fill the hostname field. See | |
12930 | @url{http://prosody.im/doc/components}. | |
12931 | Defaults to @samp{()}. | |
12932 | ||
12933 | Available @code{ext-component-configuration} fields are: | |
12934 | ||
12935 | 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: | |
12936 | @deftypevr {@code{ext-component-configuration} parameter} string component-secret | |
12937 | Password which the component will use to log in. | |
12938 | @end deftypevr | |
12939 | ||
12940 | @deftypevr {@code{ext-component-configuration} parameter} string hostname | |
12941 | Hostname of the component. | |
12942 | @end deftypevr | |
12943 | ||
12944 | @end deftypevr | |
12945 | ||
12946 | @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports | |
12947 | Port(s) Prosody listens on for component connections. | |
12948 | @end deftypevr | |
12949 | ||
12950 | @deftypevr {@code{prosody-configuration} parameter} string component-interface | |
12951 | Interface Prosody listens on for component connections. | |
12952 | Defaults to @samp{"127.0.0.1"}. | |
12953 | @end deftypevr | |
12954 | ||
12955 | It could be that you just want to get a @code{prosody.cfg.lua} | |
12956 | up and running. In that case, you can pass an | |
12957 | @code{opaque-prosody-configuration} record as the value of | |
12958 | @code{prosody-service-type}. As its name indicates, an opaque configuration | |
12959 | does not have easy reflective capabilities. | |
12960 | Available @code{opaque-prosody-configuration} fields are: | |
12961 | ||
12962 | @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody | |
12963 | The prosody package. | |
12964 | @end deftypevr | |
12965 | ||
12966 | @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua | |
12967 | The contents of the @code{prosody.cfg.lua} to use. | |
12968 | @end deftypevr | |
12969 | ||
12970 | For example, if your @code{prosody.cfg.lua} is just the empty | |
12971 | string, you could instantiate a prosody service like this: | |
12972 | ||
12973 | @example | |
12974 | (service prosody-service-type | |
12975 | (opaque-prosody-configuration | |
12976 | (prosody.cfg.lua ""))) | |
12977 | @end example | |
12978 | ||
859e367d JD |
12979 | @node Kerberos Services |
12980 | @subsubsection Kerberos Services | |
12981 | @cindex Kerberos | |
12982 | ||
df31e36a | 12983 | The @code{(gnu services kerberos)} module provides services relating to |
859e367d JD |
12984 | the authentication protocol @dfn{Kerberos}. |
12985 | ||
8e3f813f JD |
12986 | @subsubheading Krb5 Service |
12987 | ||
12988 | Programs using a Kerberos client library normally | |
12989 | expect a configuration file in @file{/etc/krb5.conf}. | |
12990 | This service generates such a file from a definition provided in the | |
12991 | operating system declaration. | |
12992 | It does not cause any daemon to be started. | |
12993 | ||
12994 | No ``keytab'' files are provided by this service---you must explicitly create them. | |
12995 | This service is known to work with the MIT client library, @code{mit-krb5}. | |
12996 | Other implementations have not been tested. | |
12997 | ||
12998 | @defvr {Scheme Variable} krb5-service-type | |
12999 | A service type for Kerberos 5 clients. | |
13000 | @end defvr | |
13001 | ||
13002 | @noindent | |
13003 | Here is an example of its use: | |
13004 | @lisp | |
13005 | (service krb5-service-type | |
13006 | (krb5-configuration | |
13007 | (default-realm "EXAMPLE.COM") | |
13008 | (allow-weak-crypto? #t) | |
13009 | (realms (list | |
13010 | (krb5-realm | |
13011 | (name "EXAMPLE.COM") | |
13012 | (admin-server "groucho.example.com") | |
13013 | (kdc "karl.example.com")) | |
13014 | (krb5-realm | |
13015 | (name "ARGRX.EDU") | |
13016 | (admin-server "kerb-admin.argrx.edu") | |
13017 | (kdc "keys.argrx.edu")))))) | |
13018 | @end lisp | |
13019 | ||
13020 | @noindent | |
13021 | This example provides a Kerberos@tie{}5 client configuration which: | |
13022 | @itemize | |
13023 | @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both | |
13024 | of which have distinct administration servers and key distribution centers; | |
13025 | @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly | |
13026 | specified by clients; | |
13027 | @item Accepts services which only support encryption types known to be weak. | |
13028 | @end itemize | |
13029 | ||
13030 | The @code{krb5-realm} and @code{krb5-configuration} types have many fields. | |
13031 | Only the most commonly used ones are described here. | |
13032 | For a full list, and more detailed explanation of each, see the MIT | |
13033 | @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf} | |
13034 | documentation. | |
13035 | ||
13036 | ||
13037 | @deftp {Data Type} krb5-realm | |
13038 | @cindex realm, kerberos | |
13039 | @table @asis | |
13040 | @item @code{name} | |
13041 | This field is a string identifying the name of the realm. | |
13042 | A common convention is to use the fully qualified DNS name of your organization, | |
13043 | converted to upper case. | |
13044 | ||
13045 | @item @code{admin-server} | |
13046 | This field is a string identifying the host where the administration server is | |
13047 | running. | |
13048 | ||
13049 | @item @code{kdc} | |
13050 | This field is a string identifying the key distribution center | |
13051 | for the realm. | |
13052 | @end table | |
13053 | @end deftp | |
13054 | ||
13055 | @deftp {Data Type} krb5-configuration | |
13056 | ||
13057 | @table @asis | |
13058 | @item @code{allow-weak-crypto?} (default: @code{#f}) | |
13059 | If this flag is @code{#t} then services which only offer encryption algorithms | |
13060 | known to be weak will be accepted. | |
13061 | ||
13062 | @item @code{default-realm} (default: @code{#f}) | |
13063 | This field should be a string identifying the default Kerberos | |
13064 | realm for the client. | |
13065 | You should set this field to the name of your Kerberos realm. | |
13066 | If this value is @code{#f} | |
13067 | then a realm must be specified with every Kerberos principal when invoking programs | |
13068 | such as @command{kinit}. | |
13069 | ||
13070 | @item @code{realms} | |
13071 | This should be a non-empty list of @code{krb5-realm} objects, which clients may | |
13072 | access. | |
13073 | Normally, one of them will have a @code{name} field matching the @code{default-realm} | |
13074 | field. | |
13075 | @end table | |
13076 | @end deftp | |
13077 | ||
13078 | ||
859e367d JD |
13079 | @subsubheading PAM krb5 Service |
13080 | @cindex pam-krb5 | |
13081 | ||
df31e36a | 13082 | The @code{pam-krb5} service allows for login authentication and password |
859e367d JD |
13083 | management via Kerberos. |
13084 | You will need this service if you want PAM enabled applications to authenticate | |
13085 | users using Kerberos. | |
13086 | ||
13087 | @defvr {Scheme Variable} pam-krb5-service-type | |
13088 | A service type for the Kerberos 5 PAM module. | |
13089 | @end defvr | |
13090 | ||
13091 | @deftp {Data Type} pam-krb5-configuration | |
13092 | Data type representing the configuration of the Kerberos 5 PAM module | |
13093 | This type has the following parameters: | |
13094 | @table @asis | |
13095 | @item @code{pam-krb5} (default: @code{pam-krb5}) | |
13096 | The pam-krb5 package to use. | |
13097 | ||
13098 | @item @code{minimum-uid} (default: @code{1000}) | |
13099 | The smallest user ID for which Kerberos authentications should be attempted. | |
13100 | Local accounts with lower values will silently fail to authenticate. | |
13101 | @end table | |
13102 | @end deftp | |
13103 | ||
13104 | ||
58724c48 DT |
13105 | @node Web Services |
13106 | @subsubsection Web Services | |
13107 | ||
e32171ee JD |
13108 | @cindex web |
13109 | @cindex www | |
13110 | @cindex HTTP | |
58724c48 DT |
13111 | The @code{(gnu services web)} module provides the following service: |
13112 | ||
be1c2c54 | 13113 | @deffn {Scheme Procedure} nginx-service [#:nginx nginx] @ |
58724c48 DT |
13114 | [#:log-directory ``/var/log/nginx''] @ |
13115 | [#:run-directory ``/var/run/nginx''] @ | |
d338237d | 13116 | [#:server-list '()] @ |
cb341293 | 13117 | [#:upstream-list '()] @ |
d338237d | 13118 | [#:config-file @code{#f}] |
58724c48 DT |
13119 | |
13120 | Return a service that runs @var{nginx}, the nginx web server. | |
13121 | ||
13122 | The nginx daemon loads its runtime configuration from @var{config-file}. | |
13123 | Log files are written to @var{log-directory} and temporary runtime data | |
13124 | files are written to @var{run-directory}. For proper operation, these | |
13125 | arguments should match what is in @var{config-file} to ensure that the | |
13126 | directories are created when the service is activated. | |
13127 | ||
3b9b12ef | 13128 | As an alternative to using a @var{config-file}, @var{server-list} can be |
cb341293 CB |
13129 | used to specify the list of @dfn{server blocks} required on the host and |
13130 | @var{upstream-list} can be used to specify a list of @dfn{upstream | |
13131 | blocks} to configure. For this to work, use the default value for | |
13132 | @var{config-file}. | |
8c00b838 | 13133 | |
58724c48 DT |
13134 | @end deffn |
13135 | ||
d338237d JL |
13136 | @deffn {Scheme Variable} nginx-service-type |
13137 | This is type for the nginx web server. | |
13138 | ||
13139 | This service can be extended to add server blocks in addition to the | |
13140 | default one, as in this example: | |
13141 | ||
13142 | @example | |
13143 | (simple-service 'my-extra-server nginx-service-type | |
13144 | (list (nginx-server-configuration | |
13145 | (https-port #f) | |
13146 | (root "/srv/http/extra-website")))) | |
13147 | @end example | |
13148 | @end deffn | |
13149 | ||
3b9b12ef JL |
13150 | @deftp {Data Type} nginx-server-configuration |
13151 | Data type representing the configuration of an nginx server block. | |
8c00b838 JL |
13152 | This type has the following parameters: |
13153 | ||
13154 | @table @asis | |
13155 | @item @code{http-port} (default: @code{80}) | |
13156 | Nginx will listen for HTTP connection on this port. Set it at @code{#f} if | |
13157 | nginx should not listen for HTTP (non secure) connection for this | |
3b9b12ef | 13158 | @dfn{server block}. |
8c00b838 JL |
13159 | |
13160 | @item @code{https-port} (default: @code{443}) | |
13161 | Nginx will listen for HTTPS connection on this port. Set it at @code{#f} if | |
3b9b12ef | 13162 | nginx should not listen for HTTPS (secure) connection for this @dfn{server block}. |
8c00b838 JL |
13163 | |
13164 | Note that nginx can listen for HTTP and HTTPS connections in the same | |
3b9b12ef | 13165 | @dfn{server block}. |
8c00b838 JL |
13166 | |
13167 | @item @code{server-name} (default: @code{(list 'default)}) | |
3b9b12ef JL |
13168 | A list of server names this server represents. @code{'default} represents the |
13169 | default server for connections matching no other server. | |
8c00b838 JL |
13170 | |
13171 | @item @code{root} (default: @code{"/srv/http"}) | |
13172 | Root of the website nginx will serve. | |
13173 | ||
9c557a69 CB |
13174 | @item @code{locations} (default: @code{'()}) |
13175 | A list of @dfn{nginx-location-configuration} or | |
13176 | @dfn{nginx-named-location-configuration} records to use within this | |
13177 | server block. | |
13178 | ||
8c00b838 JL |
13179 | @item @code{index} (default: @code{(list "index.html")}) |
13180 | Index files to look for when clients ask for a directory. If it cannot be found, | |
13181 | Nginx will send the list of files in the directory. | |
13182 | ||
13183 | @item @code{ssl-certificate} (default: @code{"/etc/nginx/cert.pem"}) | |
13184 | Where to find the certificate for secure connections. Set it to @code{#f} if | |
13185 | you don't have a certificate or you don't want to use HTTPS. | |
13186 | ||
13187 | @item @code{ssl-certificate-key} (default: @code{"/etc/nginx/key.pem"}) | |
13188 | Where to find the private key for secure connections. Set it to @code{#f} if | |
13189 | you don't have a key or you don't want to use HTTPS. | |
13190 | ||
13191 | @item @code{server-tokens?} (default: @code{#f}) | |
13192 | Whether the server should add its configuration to response. | |
13193 | ||
13194 | @end table | |
13195 | @end deftp | |
13196 | ||
2be1b471 JL |
13197 | @node VPN Services |
13198 | @subsubsection VPN Services | |
13199 | @cindex VPN (virtual private network) | |
13200 | @cindex virtual private network (VPN) | |
13201 | ||
13202 | The @code{(gnu services vpn)} module provides services related to | |
13203 | @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for | |
13204 | your machine to connect to a VPN, and a @emph{servire} service for your machine | |
13205 | to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}. | |
13206 | ||
13207 | @deffn {Scheme Procedure} openvpn-client-service @ | |
13208 | [#:config (openvpn-client-configuration)] | |
13209 | ||
13210 | Return a service that runs @command{openvpn}, a VPN daemon, as a client. | |
13211 | @end deffn | |
13212 | ||
13213 | @deffn {Scheme Procedure} openvpn-server-service @ | |
13214 | [#:config (openvpn-server-configuration)] | |
13215 | ||
13216 | Return a service that runs @command{openvpn}, a VPN daemon, as a server. | |
13217 | ||
13218 | Both can be run simultaneously. | |
13219 | @end deffn | |
13220 | ||
13221 | @c %automatically generated documentation | |
13222 | ||
13223 | Available @code{openvpn-client-configuration} fields are: | |
13224 | ||
1c17a863 | 13225 | @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn |
2be1b471 JL |
13226 | The OpenVPN package. |
13227 | ||
13228 | @end deftypevr | |
13229 | ||
1c17a863 | 13230 | @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file |
2be1b471 JL |
13231 | The OpenVPN pid file. |
13232 | ||
13233 | Defaults to @samp{"/var/run/openvpn/openvpn.pid"}. | |
13234 | ||
13235 | @end deftypevr | |
13236 | ||
1c17a863 | 13237 | @deftypevr {@code{openvpn-client-configuration} parameter} proto proto |
2be1b471 JL |
13238 | The protocol (UDP or TCP) used to open a channel between clients and |
13239 | servers. | |
13240 | ||
13241 | Defaults to @samp{udp}. | |
13242 | ||
13243 | @end deftypevr | |
13244 | ||
1c17a863 | 13245 | @deftypevr {@code{openvpn-client-configuration} parameter} dev dev |
2be1b471 JL |
13246 | The device type used to represent the VPN connection. |
13247 | ||
13248 | Defaults to @samp{tun}. | |
13249 | ||
13250 | @end deftypevr | |
13251 | ||
1c17a863 | 13252 | @deftypevr {@code{openvpn-client-configuration} parameter} string ca |
2be1b471 JL |
13253 | The certificate authority to check connections against. |
13254 | ||
13255 | Defaults to @samp{"/etc/openvpn/ca.crt"}. | |
13256 | ||
13257 | @end deftypevr | |
13258 | ||
1c17a863 | 13259 | @deftypevr {@code{openvpn-client-configuration} parameter} string cert |
2be1b471 JL |
13260 | The certificate of the machine the daemon is running on. It should be |
13261 | signed by the authority given in @code{ca}. | |
13262 | ||
13263 | Defaults to @samp{"/etc/openvpn/client.crt"}. | |
13264 | ||
13265 | @end deftypevr | |
13266 | ||
1c17a863 | 13267 | @deftypevr {@code{openvpn-client-configuration} parameter} string key |
2be1b471 JL |
13268 | The key of the machine the daemon is running on. It must be the key whose |
13269 | certificate is @code{cert}. | |
13270 | ||
13271 | Defaults to @samp{"/etc/openvpn/client.key"}. | |
13272 | ||
13273 | @end deftypevr | |
13274 | ||
1c17a863 | 13275 | @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo? |
2be1b471 JL |
13276 | Whether to use the lzo compression algorithm. |
13277 | ||
13278 | Defaults to @samp{#t}. | |
13279 | ||
13280 | @end deftypevr | |
13281 | ||
1c17a863 | 13282 | @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key? |
2be1b471 JL |
13283 | Don't re-read key files across SIGUSR1 or --ping-restart. |
13284 | ||
13285 | Defaults to @samp{#t}. | |
13286 | ||
13287 | @end deftypevr | |
13288 | ||
1c17a863 | 13289 | @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun? |
2be1b471 JL |
13290 | Don't close and reopen TUN/TAP device or run up/down scripts across |
13291 | SIGUSR1 or --ping-restart restarts. | |
13292 | ||
13293 | Defaults to @samp{#t}. | |
13294 | ||
13295 | @end deftypevr | |
13296 | ||
1c17a863 | 13297 | @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity |
2be1b471 JL |
13298 | Verbosity level. |
13299 | ||
13300 | Defaults to @samp{3}. | |
13301 | ||
13302 | @end deftypevr | |
13303 | ||
1c17a863 | 13304 | @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth |
2be1b471 JL |
13305 | Add an additional layer of HMAC authentication on top of the TLS control |
13306 | channel to protect against DoS attacks. | |
13307 | ||
13308 | Defaults to @samp{#f}. | |
13309 | ||
13310 | @end deftypevr | |
13311 | ||
1c17a863 | 13312 | @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage? |
2be1b471 JL |
13313 | Whether to check the server certificate has server usage extension. |
13314 | ||
13315 | Defaults to @samp{#t}. | |
13316 | ||
13317 | @end deftypevr | |
13318 | ||
1c17a863 | 13319 | @deftypevr {@code{openvpn-client-configuration} parameter} bind bind? |
2be1b471 JL |
13320 | Bind to a specific local port number. |
13321 | ||
13322 | Defaults to @samp{#f}. | |
13323 | ||
13324 | @end deftypevr | |
13325 | ||
1c17a863 | 13326 | @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry? |
2be1b471 JL |
13327 | Retry resolving server address. |
13328 | ||
13329 | Defaults to @samp{#t}. | |
13330 | ||
13331 | @end deftypevr | |
13332 | ||
1c17a863 | 13333 | @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote |
2be1b471 JL |
13334 | A list of remote servers to connect to. |
13335 | ||
13336 | Defaults to @samp{()}. | |
13337 | ||
13338 | Available @code{openvpn-remote-configuration} fields are: | |
13339 | ||
1c17a863 | 13340 | @deftypevr {@code{openvpn-remote-configuration} parameter} string name |
2be1b471 JL |
13341 | Server name. |
13342 | ||
13343 | Defaults to @samp{"my-server"}. | |
13344 | ||
13345 | @end deftypevr | |
13346 | ||
1c17a863 | 13347 | @deftypevr {@code{openvpn-remote-configuration} parameter} number port |
2be1b471 JL |
13348 | Port number the server listens to. |
13349 | ||
13350 | Defaults to @samp{1194}. | |
13351 | ||
13352 | @end deftypevr | |
13353 | ||
13354 | @end deftypevr | |
13355 | @c %end of automatic openvpn-client documentation | |
13356 | ||
13357 | @c %automatically generated documentation | |
13358 | ||
13359 | Available @code{openvpn-server-configuration} fields are: | |
13360 | ||
1c17a863 | 13361 | @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn |
2be1b471 JL |
13362 | The OpenVPN package. |
13363 | ||
13364 | @end deftypevr | |
13365 | ||
1c17a863 | 13366 | @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file |
2be1b471 JL |
13367 | The OpenVPN pid file. |
13368 | ||
13369 | Defaults to @samp{"/var/run/openvpn/openvpn.pid"}. | |
13370 | ||
13371 | @end deftypevr | |
13372 | ||
1c17a863 | 13373 | @deftypevr {@code{openvpn-server-configuration} parameter} proto proto |
2be1b471 JL |
13374 | The protocol (UDP or TCP) used to open a channel between clients and |
13375 | servers. | |
13376 | ||
13377 | Defaults to @samp{udp}. | |
13378 | ||
13379 | @end deftypevr | |
13380 | ||
1c17a863 | 13381 | @deftypevr {@code{openvpn-server-configuration} parameter} dev dev |
2be1b471 JL |
13382 | The device type used to represent the VPN connection. |
13383 | ||
13384 | Defaults to @samp{tun}. | |
13385 | ||
13386 | @end deftypevr | |
13387 | ||
1c17a863 | 13388 | @deftypevr {@code{openvpn-server-configuration} parameter} string ca |
2be1b471 JL |
13389 | The certificate authority to check connections against. |
13390 | ||
13391 | Defaults to @samp{"/etc/openvpn/ca.crt"}. | |
13392 | ||
13393 | @end deftypevr | |
13394 | ||
1c17a863 | 13395 | @deftypevr {@code{openvpn-server-configuration} parameter} string cert |
2be1b471 JL |
13396 | The certificate of the machine the daemon is running on. It should be |
13397 | signed by the authority given in @code{ca}. | |
13398 | ||
13399 | Defaults to @samp{"/etc/openvpn/client.crt"}. | |
13400 | ||
13401 | @end deftypevr | |
13402 | ||
1c17a863 | 13403 | @deftypevr {@code{openvpn-server-configuration} parameter} string key |
2be1b471 JL |
13404 | The key of the machine the daemon is running on. It must be the key whose |
13405 | certificate is @code{cert}. | |
13406 | ||
13407 | Defaults to @samp{"/etc/openvpn/client.key"}. | |
13408 | ||
13409 | @end deftypevr | |
13410 | ||
1c17a863 | 13411 | @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo? |
2be1b471 JL |
13412 | Whether to use the lzo compression algorithm. |
13413 | ||
13414 | Defaults to @samp{#t}. | |
13415 | ||
13416 | @end deftypevr | |
13417 | ||
1c17a863 | 13418 | @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key? |
2be1b471 JL |
13419 | Don't re-read key files across SIGUSR1 or --ping-restart. |
13420 | ||
13421 | Defaults to @samp{#t}. | |
13422 | ||
13423 | @end deftypevr | |
13424 | ||
1c17a863 | 13425 | @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun? |
2be1b471 JL |
13426 | Don't close and reopen TUN/TAP device or run up/down scripts across |
13427 | SIGUSR1 or --ping-restart restarts. | |
13428 | ||
13429 | Defaults to @samp{#t}. | |
13430 | ||
13431 | @end deftypevr | |
13432 | ||
1c17a863 | 13433 | @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity |
2be1b471 JL |
13434 | Verbosity level. |
13435 | ||
13436 | Defaults to @samp{3}. | |
13437 | ||
13438 | @end deftypevr | |
13439 | ||
1c17a863 | 13440 | @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth |
2be1b471 JL |
13441 | Add an additional layer of HMAC authentication on top of the TLS control |
13442 | channel to protect against DoS attacks. | |
13443 | ||
13444 | Defaults to @samp{#f}. | |
13445 | ||
13446 | @end deftypevr | |
13447 | ||
1c17a863 | 13448 | @deftypevr {@code{openvpn-server-configuration} parameter} number port |
2be1b471 JL |
13449 | Specifies the port number on which the server listens. |
13450 | ||
13451 | Defaults to @samp{1194}. | |
13452 | ||
13453 | @end deftypevr | |
13454 | ||
1c17a863 | 13455 | @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server |
2be1b471 JL |
13456 | An ip and mask specifying the subnet inside the virtual network. |
13457 | ||
13458 | Defaults to @samp{"10.8.0.0 255.255.255.0"}. | |
13459 | ||
13460 | @end deftypevr | |
13461 | ||
1c17a863 | 13462 | @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6 |
2be1b471 JL |
13463 | A CIDR notation specifying the IPv6 subnet inside the virtual network. |
13464 | ||
13465 | Defaults to @samp{#f}. | |
13466 | ||
13467 | @end deftypevr | |
13468 | ||
1c17a863 | 13469 | @deftypevr {@code{openvpn-server-configuration} parameter} string dh |
2be1b471 JL |
13470 | The Diffie-Hellman parameters file. |
13471 | ||
13472 | Defaults to @samp{"/etc/openvpn/dh2048.pem"}. | |
13473 | ||
13474 | @end deftypevr | |
13475 | ||
1c17a863 | 13476 | @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist |
2be1b471 JL |
13477 | The file that records client IPs. |
13478 | ||
13479 | Defaults to @samp{"/etc/openvpn/ipp.txt"}. | |
13480 | ||
13481 | @end deftypevr | |
13482 | ||
1c17a863 | 13483 | @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway? |
2be1b471 JL |
13484 | When true, the server will act as a gateway for its clients. |
13485 | ||
13486 | Defaults to @samp{#f}. | |
13487 | ||
13488 | @end deftypevr | |
13489 | ||
1c17a863 | 13490 | @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client? |
9fc221b5 | 13491 | When true, clients are allowed to talk to each other inside the VPN. |
2be1b471 JL |
13492 | |
13493 | Defaults to @samp{#f}. | |
13494 | ||
13495 | @end deftypevr | |
13496 | ||
1c17a863 | 13497 | @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive |
2be1b471 JL |
13498 | Causes ping-like messages to be sent back and forth over the link so |
13499 | that each side knows when the other side has gone down. @code{keepalive} | |
13500 | requires a pair. The first element is the period of the ping sending, | |
13501 | and the second element is the timeout before considering the other side | |
13502 | down. | |
13503 | ||
13504 | @end deftypevr | |
13505 | ||
1c17a863 | 13506 | @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients |
2be1b471 JL |
13507 | The maximum number of clients. |
13508 | ||
13509 | Defaults to @samp{100}. | |
13510 | ||
13511 | @end deftypevr | |
13512 | ||
1c17a863 | 13513 | @deftypevr {@code{openvpn-server-configuration} parameter} string status |
2be1b471 | 13514 | The status file. This file shows a small report on current connection. |
9fc221b5 | 13515 | It is truncated and rewritten every minute. |
2be1b471 JL |
13516 | |
13517 | Defaults to @samp{"/var/run/openvpn/status"}. | |
13518 | ||
13519 | @end deftypevr | |
13520 | ||
1c17a863 | 13521 | @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir |
2be1b471 JL |
13522 | The list of configuration for some clients. |
13523 | ||
13524 | Defaults to @samp{()}. | |
13525 | ||
13526 | Available @code{openvpn-ccd-configuration} fields are: | |
13527 | ||
1c17a863 | 13528 | @deftypevr {@code{openvpn-ccd-configuration} parameter} string name |
2be1b471 JL |
13529 | Client name. |
13530 | ||
13531 | Defaults to @samp{"client"}. | |
13532 | ||
13533 | @end deftypevr | |
13534 | ||
1c17a863 | 13535 | @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute |
2be1b471 JL |
13536 | Client own network |
13537 | ||
13538 | Defaults to @samp{#f}. | |
13539 | ||
13540 | @end deftypevr | |
13541 | ||
1c17a863 | 13542 | @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push |
2be1b471 JL |
13543 | Client VPN IP. |
13544 | ||
13545 | Defaults to @samp{#f}. | |
13546 | ||
13547 | @end deftypevr | |
13548 | ||
13549 | @end deftypevr | |
13550 | ||
13551 | ||
13552 | @c %end of automatic openvpn-server documentation | |
13553 | ||
13554 | ||
cb341293 CB |
13555 | @deftp {Data Type} nginx-upstream-configuration |
13556 | Data type representing the configuration of an nginx @code{upstream} | |
13557 | block. This type has the following parameters: | |
13558 | ||
13559 | @table @asis | |
13560 | @item @code{name} | |
13561 | Name for this group of servers. | |
13562 | ||
13563 | @item @code{servers} | |
13564 | Specify the addresses of the servers in the group. The address can be | |
13565 | specified as a IP address (e.g. @samp{127.0.0.1}), domain name | |
13566 | (e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the | |
13567 | prefix @samp{unix:}. For addresses using an IP address or domain name, | |
13568 | the default port is 80, and a different port can be specified | |
13569 | explicitly. | |
13570 | ||
13571 | @end table | |
13572 | @end deftp | |
13573 | ||
9c557a69 CB |
13574 | @deftp {Data Type} nginx-location-configuration |
13575 | Data type representing the configuration of an nginx @code{location} | |
13576 | block. This type has the following parameters: | |
13577 | ||
13578 | @table @asis | |
13579 | @item @code{uri} | |
13580 | URI which this location block matches. | |
13581 | ||
13582 | @anchor{nginx-location-configuration body} | |
13583 | @item @code{body} | |
13584 | Body of the location block, specified as a string. This can contain many | |
13585 | configuration directives. For example, to pass requests to a upstream | |
13586 | server group defined using an @code{nginx-upstream-configuration} block, | |
13587 | the following directive would be specified in the body @samp{proxy_pass | |
13588 | http://upstream-name;}. | |
13589 | ||
13590 | @end table | |
13591 | @end deftp | |
13592 | ||
13593 | @deftp {Data Type} nginx-named-location-configuration | |
13594 | Data type representing the configuration of an nginx named location | |
13595 | block. Named location blocks are used for request redirection, and not | |
13596 | used for regular request processing. This type has the following | |
13597 | parameters: | |
13598 | ||
13599 | @table @asis | |
13600 | @item @code{name} | |
13601 | Name to identify this location block. | |
13602 | ||
13603 | @item @code{body} | |
13604 | @xref{nginx-location-configuration body}, as the body for named location | |
13605 | blocks can be used in a similar way to the | |
13606 | @code{nginx-location-configuration body}. One restriction is that the | |
13607 | body of a named location block cannot contain location blocks. | |
13608 | ||
13609 | @end table | |
13610 | @end deftp | |
13611 | ||
eb419bc9 JD |
13612 | @node Network File System |
13613 | @subsubsection Network File System | |
13614 | @cindex NFS | |
fe1a39d3 | 13615 | |
eb419bc9 JD |
13616 | The @code{(gnu services nfs)} module provides the following services, |
13617 | which are most commonly used in relation to mounting or exporting | |
13618 | directory trees as @dfn{network file systems} (NFS). | |
d6a07ee6 JD |
13619 | |
13620 | @subsubheading RPC Bind Service | |
13621 | @cindex rpcbind | |
13622 | ||
eb419bc9 JD |
13623 | The RPC Bind service provides a facility to map program numbers into |
13624 | universal addresses. | |
13625 | Many NFS related services use this facility. Hence it is automatically | |
13626 | started when a dependent service starts. | |
d6a07ee6 JD |
13627 | |
13628 | @defvr {Scheme Variable} rpcbind-service-type | |
13629 | A service type for the RPC portmapper daemon. | |
13630 | @end defvr | |
13631 | ||
13632 | ||
13633 | @deftp {Data Type} rpcbind-configuration | |
13634 | Data type representing the configuration of the RPC Bind Service. | |
13635 | This type has the following parameters: | |
13636 | @table @asis | |
13637 | @item @code{rpcbind} (default: @code{rpcbind}) | |
13638 | The rpcbind package to use. | |
13639 | ||
13640 | @item @code{warm-start?} (default: @code{#t}) | |
13641 | If this parameter is @code{#t}, then the daemon will read a | |
13642 | state file on startup thus reloading state information saved by a previous | |
13643 | instance. | |
13644 | @end table | |
13645 | @end deftp | |
13646 | ||
eb419bc9 JD |
13647 | |
13648 | @subsubheading Pipefs Pseudo File System | |
13649 | @cindex pipefs | |
13650 | @cindex rpc_pipefs | |
13651 | ||
13652 | The pipefs file system is used to transfer NFS related data | |
13653 | between the kernel and user space programs. | |
13654 | ||
13655 | @defvr {Scheme Variable} pipefs-service-type | |
13656 | A service type for the pipefs pseudo file system. | |
13657 | @end defvr | |
13658 | ||
13659 | @deftp {Data Type} pipefs-configuration | |
13660 | Data type representing the configuration of the pipefs pseudo file system service. | |
13661 | This type has the following parameters: | |
13662 | @table @asis | |
13663 | @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13664 | The directory to which the file system is to be attached. | |
13665 | @end table | |
13666 | @end deftp | |
13667 | ||
13668 | ||
13669 | @subsubheading GSS Daemon Service | |
13670 | @cindex GSSD | |
13671 | @cindex GSS | |
13672 | @cindex global security system | |
13673 | ||
13674 | The @dfn{global security system} (GSS) daemon provides strong security for RPC | |
13675 | based protocols. | |
13676 | Before exchanging RPC requests an RPC client must establish a security | |
13677 | context. Typically this is done using the Kerberos command @command{kinit} | |
859e367d | 13678 | or automatically at login time using PAM services (@pxref{Kerberos Services}). |
eb419bc9 JD |
13679 | |
13680 | @defvr {Scheme Variable} gss-service-type | |
13681 | A service type for the Global Security System (GSS) daemon. | |
13682 | @end defvr | |
13683 | ||
13684 | @deftp {Data Type} gss-configuration | |
13685 | Data type representing the configuration of the GSS daemon service. | |
13686 | This type has the following parameters: | |
13687 | @table @asis | |
13688 | @item @code{nfs-utils} (default: @code{nfs-utils}) | |
13689 | The package in which the @command{rpc.gssd} command is to be found. | |
13690 | ||
13691 | @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13692 | The directory where the pipefs file system is mounted. | |
13693 | ||
13694 | @end table | |
13695 | @end deftp | |
13696 | ||
13697 | ||
13698 | @subsubheading IDMAP Daemon Service | |
13699 | @cindex idmapd | |
13700 | @cindex name mapper | |
13701 | ||
13702 | The idmap daemon service provides mapping between user IDs and user names. | |
13703 | Typically it is required in order to access file systems mounted via NFSv4. | |
13704 | ||
13705 | @defvr {Scheme Variable} idmap-service-type | |
13706 | A service type for the Identity Mapper (IDMAP) daemon. | |
13707 | @end defvr | |
13708 | ||
13709 | @deftp {Data Type} idmap-configuration | |
13710 | Data type representing the configuration of the IDMAP daemon service. | |
13711 | This type has the following parameters: | |
13712 | @table @asis | |
13713 | @item @code{nfs-utils} (default: @code{nfs-utils}) | |
13714 | The package in which the @command{rpc.idmapd} command is to be found. | |
13715 | ||
13716 | @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13717 | The directory where the pipefs file system is mounted. | |
13718 | ||
13719 | @item @code{domain} (default: @code{#f}) | |
13720 | The local NFSv4 domain name. | |
13721 | This must be a string or @code{#f}. | |
13722 | If it is @code{#f} then the daemon will use the host's fully qualified domain name. | |
13723 | ||
13724 | @end table | |
13725 | @end deftp | |
13726 | ||
a7cf4eb6 ML |
13727 | @node Continuous Integration |
13728 | @subsubsection Continuous Integration | |
13729 | ||
13730 | @cindex continuous integration | |
13731 | @uref{https://notabug.org/mthl/cuirass, Cuirass} is a continuous | |
13732 | integration tool for Guix. It can be used both for development and for | |
13733 | providing substitutes to others (@pxref{Substitutes}). | |
13734 | ||
13735 | The @code{(gnu services cuirass)} module provides the following service. | |
13736 | ||
231eddc8 LC |
13737 | @defvr {Scheme Procedure} cuirass-service-type |
13738 | The type of the Cuirass service. Its value must be a | |
13739 | @code{cuirass-configuration} object, as described below. | |
13740 | @end defvr | |
a7cf4eb6 | 13741 | |
231eddc8 LC |
13742 | To add build jobs, you have to set the @code{specifications} field of |
13743 | the configuration. Here is an example of a service defining a build job | |
13744 | based on a specification that can be found in Cuirass source tree. This | |
13745 | service polls the Guix repository and builds a subset of the Guix | |
13746 | packages, as prescribed in the @file{gnu-system.scm} example spec: | |
a7cf4eb6 ML |
13747 | |
13748 | @example | |
8de938d5 LC |
13749 | (let ((spec #~((#:name . "guix") |
13750 | (#:url . "git://git.savannah.gnu.org/guix.git") | |
13751 | (#:load-path . ".") | |
13752 | ||
13753 | ;; Here we must provide an absolute file name. | |
13754 | ;; We take jobs from one of the examples provided | |
13755 | ;; by Cuirass. | |
13756 | (#:file . #$(file-append | |
13757 | cuirass | |
13758 | "/tests/gnu-system.scm")) | |
13759 | ||
13760 | (#:proc . hydra-jobs) | |
13761 | (#:arguments (subset . "hello")) | |
13762 | (#:branch . "master")))) | |
231eddc8 LC |
13763 | (service cuirass-service-type |
13764 | (cuirass-configuration | |
13765 | (specifications #~(list #$spec))))) | |
a7cf4eb6 ML |
13766 | @end example |
13767 | ||
231eddc8 | 13768 | While information related to build jobs is located directly in the |
a7cf4eb6 ML |
13769 | specifications, global settings for the @command{cuirass} process are |
13770 | accessible in other @code{cuirass-configuration} fields. | |
13771 | ||
13772 | @deftp {Data Type} cuirass-configuration | |
13773 | Data type representing the configuration of Cuirass. | |
13774 | ||
13775 | @table @asis | |
b17e326f LC |
13776 | @item @code{log-file} (default: @code{"/var/log/cuirass.log"}) |
13777 | Location of the log file. | |
13778 | ||
463995da | 13779 | @item @code{cache-directory} (default: @code{"/var/cache/cuirass"}) |
a7cf4eb6 ML |
13780 | Location of the repository cache. |
13781 | ||
13782 | @item @code{user} (default: @code{"cuirass"}) | |
13783 | Owner of the @code{cuirass} process. | |
13784 | ||
13785 | @item @code{group} (default: @code{"cuirass"}) | |
13786 | Owner's group of the @code{cuirass} process. | |
13787 | ||
13788 | @item @code{interval} (default: @code{60}) | |
13789 | Number of seconds between the poll of the repositories followed by the | |
13790 | Cuirass jobs. | |
13791 | ||
13792 | @item @code{database} (default: @code{"/var/run/cuirass/cuirass.db"}) | |
13793 | Location of sqlite database which contains the build results and previously | |
13794 | added specifications. | |
13795 | ||
11b7717d MO |
13796 | @item @code{port} (default: @code{8080}) |
13797 | Port number used by the HTTP server. | |
13798 | ||
8de938d5 LC |
13799 | @item @code{specifications} (default: @code{#~'()}) |
13800 | A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications, | |
13801 | where a specification is an association list | |
a7cf4eb6 ML |
13802 | (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose |
13803 | keys are keywords (@code{#:keyword-example}) as shown in the example | |
13804 | above. | |
13805 | ||
13806 | @item @code{use-substitutes?} (default: @code{#f}) | |
13807 | This allows using substitutes to avoid building every dependencies of a job | |
13808 | from source. | |
13809 | ||
13810 | @item @code{one-shot?} (default: @code{#f}) | |
13811 | Only evaluate specifications and build derivations once. | |
379b6ba5 | 13812 | |
eb122280 MO |
13813 | @item @code{load-path} (default: @code{'()}) |
13814 | This allows users to define their own packages and make them visible to | |
13815 | cuirass as in @command{guix build} command. | |
13816 | ||
379b6ba5 LC |
13817 | @item @code{cuirass} (default: @code{cuirass}) |
13818 | The Cuirass package to use. | |
a7cf4eb6 ML |
13819 | @end table |
13820 | @end deftp | |
eb419bc9 | 13821 | |
bfbf6e1e MO |
13822 | @node Power management Services |
13823 | @subsubsection Power management Services | |
13824 | ||
13825 | @cindex power management with TLP | |
13826 | The @code{(gnu services pm)} module provides a Guix service definition | |
13827 | for the Linux power management tool TLP. | |
13828 | ||
13829 | TLP enables various powersaving modes in userspace and kernel. | |
13830 | Contrary to @code{upower-service}, it is not a passive, | |
13831 | monitoring tool, as it will apply custom settings each time a new power | |
13832 | source is detected. More information can be found at | |
13833 | @uref{http://linrunner.de/en/tlp/tlp.html, TLP home page}. | |
13834 | ||
13835 | @deffn {Scheme Variable} tlp-service-type | |
13836 | The service type for the TLP tool. Its value should be a valid | |
13837 | TLP configuration (see below). For example: | |
13838 | @example | |
13839 | (service tlp-service-type (tlp-configuration)) | |
13840 | @end example | |
13841 | @end deffn | |
13842 | ||
13843 | By default TLP does not need much configuration but most TLP parameters | |
13844 | can be tweaked using @code{tlp-configuration}. | |
13845 | ||
13846 | Each parameter definition is preceded by its type; for example, | |
13847 | @samp{boolean foo} indicates that the @code{foo} parameter | |
13848 | should be specified as a boolean. Types starting with | |
13849 | @code{maybe-} denote parameters that won't show up in TLP config file | |
13850 | when their value is @code{'disabled}. | |
13851 | ||
13852 | @c The following documentation was initially generated by | |
13853 | @c (generate-tlp-documentation) in (gnu services pm). Manually maintained | |
13854 | @c documentation is better, so we shouldn't hesitate to edit below as | |
13855 | @c needed. However if the change you want to make to this documentation | |
13856 | @c can be done in an automated way, it's probably easier to change | |
13857 | @c (generate-documentation) than to make it below and have to deal with | |
13858 | @c the churn as TLP updates. | |
13859 | ||
13860 | Available @code{tlp-configuration} fields are: | |
13861 | ||
13862 | @deftypevr {@code{tlp-configuration} parameter} package tlp | |
13863 | The TLP package. | |
13864 | ||
13865 | @end deftypevr | |
13866 | ||
13867 | @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable? | |
13868 | Set to true if you wish to enable TLP. | |
13869 | ||
13870 | Defaults to @samp{#t}. | |
13871 | ||
13872 | @end deftypevr | |
13873 | ||
13874 | @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode | |
13875 | Default mode when no power supply can be detected. Alternatives are AC | |
13876 | and BAT. | |
13877 | ||
13878 | Defaults to @samp{"AC"}. | |
13879 | ||
13880 | @end deftypevr | |
13881 | ||
13882 | @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac | |
13883 | Number of seconds Linux kernel has to wait after the disk goes idle, | |
13884 | before syncing on AC. | |
13885 | ||
13886 | Defaults to @samp{0}. | |
13887 | ||
13888 | @end deftypevr | |
13889 | ||
13890 | @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat | |
13891 | Same as @code{disk-idle-ac} but on BAT mode. | |
13892 | ||
13893 | Defaults to @samp{2}. | |
13894 | ||
13895 | @end deftypevr | |
13896 | ||
13897 | @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac | |
13898 | Dirty pages flushing periodicity, expressed in seconds. | |
13899 | ||
13900 | Defaults to @samp{15}. | |
13901 | ||
13902 | @end deftypevr | |
13903 | ||
13904 | @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat | |
13905 | Same as @code{max-lost-work-secs-on-ac} but on BAT mode. | |
13906 | ||
13907 | Defaults to @samp{60}. | |
13908 | ||
13909 | @end deftypevr | |
13910 | ||
13911 | @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac | |
13912 | CPU frequency scaling governor on AC mode. With intel_pstate driver, | |
13913 | alternatives are powersave and performance. With acpi-cpufreq driver, | |
13914 | alternatives are ondemand, powersave, performance and conservative. | |
13915 | ||
13916 | Defaults to @samp{disabled}. | |
13917 | ||
13918 | @end deftypevr | |
13919 | ||
13920 | @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat | |
13921 | Same as @code{cpu-scaling-governor-on-ac} but on BAT mode. | |
13922 | ||
13923 | Defaults to @samp{disabled}. | |
13924 | ||
13925 | @end deftypevr | |
13926 | ||
13927 | @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac | |
13928 | Set the min available frequency for the scaling governor on AC. | |
13929 | ||
13930 | Defaults to @samp{disabled}. | |
13931 | ||
13932 | @end deftypevr | |
13933 | ||
13934 | @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac | |
13935 | Set the max available frequency for the scaling governor on AC. | |
13936 | ||
13937 | Defaults to @samp{disabled}. | |
13938 | ||
13939 | @end deftypevr | |
13940 | ||
13941 | @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat | |
13942 | Set the min available frequency for the scaling governor on BAT. | |
13943 | ||
13944 | Defaults to @samp{disabled}. | |
13945 | ||
13946 | @end deftypevr | |
13947 | ||
13948 | @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat | |
13949 | Set the max available frequency for the scaling governor on BAT. | |
13950 | ||
13951 | Defaults to @samp{disabled}. | |
13952 | ||
13953 | @end deftypevr | |
13954 | ||
13955 | @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac | |
13956 | Limit the min P-state to control the power dissipation of the CPU, in AC | |
13957 | mode. Values are stated as a percentage of the available performance. | |
13958 | ||
13959 | Defaults to @samp{disabled}. | |
13960 | ||
13961 | @end deftypevr | |
13962 | ||
13963 | @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac | |
13964 | Limit the max P-state to control the power dissipation of the CPU, in AC | |
13965 | mode. Values are stated as a percentage of the available performance. | |
13966 | ||
13967 | Defaults to @samp{disabled}. | |
13968 | ||
13969 | @end deftypevr | |
13970 | ||
13971 | @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat | |
13972 | Same as @code{cpu-min-perf-on-ac} on BAT mode. | |
13973 | ||
13974 | Defaults to @samp{disabled}. | |
13975 | ||
13976 | @end deftypevr | |
13977 | ||
13978 | @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat | |
13979 | Same as @code{cpu-max-perf-on-ac} on BAT mode. | |
13980 | ||
13981 | Defaults to @samp{disabled}. | |
13982 | ||
13983 | @end deftypevr | |
13984 | ||
13985 | @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac? | |
13986 | Enable CPU turbo boost feature on AC mode. | |
13987 | ||
13988 | Defaults to @samp{disabled}. | |
13989 | ||
13990 | @end deftypevr | |
13991 | ||
13992 | @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat? | |
13993 | Same as @code{cpu-boost-on-ac?} on BAT mode. | |
13994 | ||
13995 | Defaults to @samp{disabled}. | |
13996 | ||
13997 | @end deftypevr | |
13998 | ||
13999 | @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac? | |
14000 | Allow Linux kernel to minimize the number of CPU cores/hyper-threads | |
14001 | used under light load conditions. | |
14002 | ||
14003 | Defaults to @samp{#f}. | |
14004 | ||
14005 | @end deftypevr | |
14006 | ||
14007 | @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat? | |
14008 | Same as @code{sched-powersave-on-ac?} but on BAT mode. | |
14009 | ||
14010 | Defaults to @samp{#t}. | |
14011 | ||
14012 | @end deftypevr | |
14013 | ||
14014 | @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog? | |
14015 | Enable Linux kernel NMI watchdog. | |
14016 | ||
14017 | Defaults to @samp{#f}. | |
14018 | ||
14019 | @end deftypevr | |
14020 | ||
14021 | @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls | |
14022 | For Linux kernels with PHC patch applied, change CPU voltages. An | |
14023 | example value would be @samp{"F:V F:V F:V F:V"}. | |
14024 | ||
14025 | Defaults to @samp{disabled}. | |
14026 | ||
14027 | @end deftypevr | |
14028 | ||
14029 | @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac | |
14030 | Set CPU performance versus energy saving policy on AC. Alternatives are | |
14031 | performance, normal, powersave. | |
14032 | ||
14033 | Defaults to @samp{"performance"}. | |
14034 | ||
14035 | @end deftypevr | |
14036 | ||
14037 | @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat | |
14038 | Same as @code{energy-perf-policy-ac} but on BAT mode. | |
14039 | ||
14040 | Defaults to @samp{"powersave"}. | |
14041 | ||
14042 | @end deftypevr | |
14043 | ||
14044 | @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices | |
14045 | Hard disk devices. | |
14046 | ||
14047 | @end deftypevr | |
14048 | ||
14049 | @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac | |
14050 | Hard disk advanced power management level. | |
14051 | ||
14052 | @end deftypevr | |
14053 | ||
14054 | @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat | |
14055 | Same as @code{disk-apm-bat} but on BAT mode. | |
14056 | ||
14057 | @end deftypevr | |
14058 | ||
14059 | @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac | |
14060 | Hard disk spin down timeout. One value has to be specified for each | |
14061 | declared hard disk. | |
14062 | ||
14063 | Defaults to @samp{disabled}. | |
14064 | ||
14065 | @end deftypevr | |
14066 | ||
14067 | @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat | |
14068 | Same as @code{disk-spindown-timeout-on-ac} but on BAT mode. | |
14069 | ||
14070 | Defaults to @samp{disabled}. | |
14071 | ||
14072 | @end deftypevr | |
14073 | ||
14074 | @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched | |
14075 | Select IO scheduler for disk devices. One value has to be specified for | |
14076 | each declared hard disk. Example alternatives are cfq, deadline and | |
14077 | noop. | |
14078 | ||
14079 | Defaults to @samp{disabled}. | |
14080 | ||
14081 | @end deftypevr | |
14082 | ||
14083 | @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac | |
14084 | SATA aggressive link power management (ALPM) level. Alternatives are | |
14085 | min_power, medium_power, max_performance. | |
14086 | ||
14087 | Defaults to @samp{"max_performance"}. | |
14088 | ||
14089 | @end deftypevr | |
14090 | ||
14091 | @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat | |
14092 | Same as @code{sata-linkpwr-ac} but on BAT mode. | |
14093 | ||
14094 | Defaults to @samp{"min_power"}. | |
14095 | ||
14096 | @end deftypevr | |
14097 | ||
14098 | @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist | |
14099 | Exclude specified SATA host devices for link power management. | |
14100 | ||
14101 | Defaults to @samp{disabled}. | |
14102 | ||
14103 | @end deftypevr | |
14104 | ||
14105 | @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac? | |
14106 | Enable Runtime Power Management for AHCI controller and disks on AC | |
14107 | mode. | |
14108 | ||
14109 | Defaults to @samp{disabled}. | |
14110 | ||
14111 | @end deftypevr | |
14112 | ||
14113 | @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat? | |
14114 | Same as @code{ahci-runtime-pm-on-ac} on BAT mode. | |
14115 | ||
14116 | Defaults to @samp{disabled}. | |
14117 | ||
14118 | @end deftypevr | |
14119 | ||
14120 | @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout | |
14121 | Seconds of inactivity before disk is suspended. | |
14122 | ||
14123 | Defaults to @samp{15}. | |
14124 | ||
14125 | @end deftypevr | |
14126 | ||
14127 | @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac | |
14128 | PCI Express Active State Power Management level. Alternatives are | |
14129 | default, performance, powersave. | |
14130 | ||
14131 | Defaults to @samp{"performance"}. | |
14132 | ||
14133 | @end deftypevr | |
14134 | ||
14135 | @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat | |
14136 | Same as @code{pcie-aspm-ac} but on BAT mode. | |
14137 | ||
14138 | Defaults to @samp{"powersave"}. | |
14139 | ||
14140 | @end deftypevr | |
14141 | ||
14142 | @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac | |
14143 | Radeon graphics clock speed level. Alternatives are low, mid, high, | |
14144 | auto, default. | |
14145 | ||
14146 | Defaults to @samp{"high"}. | |
14147 | ||
14148 | @end deftypevr | |
14149 | ||
14150 | @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat | |
14151 | Same as @code{radeon-power-ac} but on BAT mode. | |
14152 | ||
14153 | Defaults to @samp{"low"}. | |
14154 | ||
14155 | @end deftypevr | |
14156 | ||
14157 | @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac | |
14158 | Radeon dynamic power management method (DPM). Alternatives are battery, | |
14159 | performance. | |
14160 | ||
14161 | Defaults to @samp{"performance"}. | |
14162 | ||
14163 | @end deftypevr | |
14164 | ||
14165 | @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat | |
14166 | Same as @code{radeon-dpm-state-ac} but on BAT mode. | |
14167 | ||
14168 | Defaults to @samp{"battery"}. | |
14169 | ||
14170 | @end deftypevr | |
14171 | ||
14172 | @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac | |
14173 | Radeon DPM performance level. Alternatives are auto, low, high. | |
14174 | ||
14175 | Defaults to @samp{"auto"}. | |
14176 | ||
14177 | @end deftypevr | |
14178 | ||
14179 | @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat | |
14180 | Same as @code{radeon-dpm-perf-ac} but on BAT mode. | |
14181 | ||
14182 | Defaults to @samp{"auto"}. | |
14183 | ||
14184 | @end deftypevr | |
14185 | ||
14186 | @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac? | |
14187 | Wifi power saving mode. | |
14188 | ||
14189 | Defaults to @samp{#f}. | |
14190 | ||
14191 | @end deftypevr | |
14192 | ||
14193 | @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat? | |
14194 | Same as @code{wifi-power-ac?} but on BAT mode. | |
14195 | ||
14196 | Defaults to @samp{#t}. | |
14197 | ||
14198 | @end deftypevr | |
14199 | ||
14200 | @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable? | |
14201 | Disable wake on LAN. | |
14202 | ||
14203 | Defaults to @samp{#t}. | |
14204 | ||
14205 | @end deftypevr | |
14206 | ||
14207 | @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac | |
14208 | Timeout duration in seconds before activating audio power saving on | |
14209 | Intel HDA and AC97 devices. A value of 0 disables power saving. | |
14210 | ||
14211 | Defaults to @samp{0}. | |
14212 | ||
14213 | @end deftypevr | |
14214 | ||
14215 | @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat | |
14216 | Same as @code{sound-powersave-ac} but on BAT mode. | |
14217 | ||
14218 | Defaults to @samp{1}. | |
14219 | ||
14220 | @end deftypevr | |
14221 | ||
14222 | @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller? | |
14223 | Disable controller in powersaving mode on Intel HDA devices. | |
14224 | ||
14225 | Defaults to @samp{#t}. | |
14226 | ||
14227 | @end deftypevr | |
14228 | ||
14229 | @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat? | |
14230 | Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be | |
14231 | powered on again by releasing (and reinserting) the eject lever or by | |
14232 | pressing the disc eject button on newer models. | |
14233 | ||
14234 | Defaults to @samp{#f}. | |
14235 | ||
14236 | @end deftypevr | |
14237 | ||
14238 | @deftypevr {@code{tlp-configuration} parameter} string bay-device | |
14239 | Name of the optical drive device to power off. | |
14240 | ||
14241 | Defaults to @samp{"sr0"}. | |
14242 | ||
14243 | @end deftypevr | |
14244 | ||
14245 | @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac | |
14246 | Runtime Power Management for PCI(e) bus devices. Alternatives are on | |
14247 | and auto. | |
14248 | ||
14249 | Defaults to @samp{"on"}. | |
14250 | ||
14251 | @end deftypevr | |
14252 | ||
14253 | @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat | |
14254 | Same as @code{runtime-pm-ac} but on BAT mode. | |
14255 | ||
14256 | Defaults to @samp{"auto"}. | |
14257 | ||
14258 | @end deftypevr | |
14259 | ||
14260 | @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all? | |
14261 | Runtime Power Management for all PCI(e) bus devices, except blacklisted | |
14262 | ones. | |
14263 | ||
14264 | Defaults to @samp{#t}. | |
14265 | ||
14266 | @end deftypevr | |
14267 | ||
14268 | @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist | |
9fc221b5 | 14269 | Exclude specified PCI(e) device addresses from Runtime Power Management. |
bfbf6e1e MO |
14270 | |
14271 | Defaults to @samp{disabled}. | |
14272 | ||
14273 | @end deftypevr | |
14274 | ||
14275 | @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist | |
14276 | Exclude PCI(e) devices assigned to the specified drivers from Runtime | |
14277 | Power Management. | |
14278 | ||
14279 | @end deftypevr | |
14280 | ||
14281 | @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend? | |
14282 | Enable USB autosuspend feature. | |
14283 | ||
14284 | Defaults to @samp{#t}. | |
14285 | ||
14286 | @end deftypevr | |
14287 | ||
14288 | @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist | |
14289 | Exclude specified devices from USB autosuspend. | |
14290 | ||
14291 | Defaults to @samp{disabled}. | |
14292 | ||
14293 | @end deftypevr | |
14294 | ||
14295 | @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan? | |
14296 | Exclude WWAN devices from USB autosuspend. | |
14297 | ||
14298 | Defaults to @samp{#t}. | |
14299 | ||
14300 | @end deftypevr | |
14301 | ||
14302 | @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist | |
14303 | Include specified devices into USB autosuspend, even if they are already | |
14304 | excluded by the driver or via @code{usb-blacklist-wwan?}. | |
14305 | ||
14306 | Defaults to @samp{disabled}. | |
14307 | ||
14308 | @end deftypevr | |
14309 | ||
14310 | @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown? | |
14311 | Enable USB autosuspend before shutdown. | |
14312 | ||
14313 | Defaults to @samp{disabled}. | |
14314 | ||
14315 | @end deftypevr | |
14316 | ||
14317 | @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup? | |
14318 | Restore radio device state (bluetooth, wifi, wwan) from previous | |
14319 | shutdown on system startup. | |
14320 | ||
14321 | Defaults to @samp{#f}. | |
14322 | ||
14323 | @end deftypevr | |
14324 | ||
eb419bc9 JD |
14325 | @node Miscellaneous Services |
14326 | @subsubsection Miscellaneous Services | |
14327 | ||
14328 | ||
8ff4dcbe DC |
14329 | @cindex lirc |
14330 | @subsubheading Lirc Service | |
14331 | ||
fe1a39d3 LC |
14332 | The @code{(gnu services lirc)} module provides the following service. |
14333 | ||
be1c2c54 | 14334 | @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @ |
fe1a39d3 LC |
14335 | [#:device #f] [#:driver #f] [#:config-file #f] @ |
14336 | [#:extra-options '()] | |
14337 | Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that | |
14338 | decodes infrared signals from remote controls. | |
14339 | ||
14340 | Optionally, @var{device}, @var{driver} and @var{config-file} | |
14341 | (configuration file name) may be specified. See @command{lircd} manual | |
14342 | for details. | |
14343 | ||
14344 | Finally, @var{extra-options} is a list of additional command-line options | |
14345 | passed to @command{lircd}. | |
14346 | @end deffn | |
14347 | ||
00f46905 DC |
14348 | @cindex spice |
14349 | @subsubheading Spice Service | |
14350 | ||
14351 | The @code{(gnu services spice)} module provides the following service. | |
14352 | ||
14353 | @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent] | |
14354 | Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon | |
14355 | that enables sharing the clipboard with a vm and setting the guest display | |
14356 | resolution when the graphical console window resizes. | |
14357 | @end deffn | |
14358 | ||
c3d38b2b | 14359 | @subsubsection Dictionary Services |
e32171ee | 14360 | @cindex dictionary |
c3d38b2b SB |
14361 | The @code{(gnu services dict)} module provides the following service: |
14362 | ||
14363 | @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)] | |
14364 | Return a service that runs the @command{dicod} daemon, an implementation | |
14365 | of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}). | |
14366 | ||
14367 | The optional @var{config} argument specifies the configuration for | |
14368 | @command{dicod}, which should be a @code{<dicod-configuration>} object, by | |
14369 | default it serves the GNU Collaborative International Dictonary of English. | |
14370 | ||
14371 | You can add @command{open localhost} to your @file{~/.dico} file to make | |
14372 | @code{localhost} the default server for @command{dico} client | |
14373 | (@pxref{Initialization File,,, dico, GNU Dico Manual}). | |
14374 | @end deffn | |
14375 | ||
14376 | @deftp {Data Type} dicod-configuration | |
14377 | Data type representing the configuration of dicod. | |
14378 | ||
14379 | @table @asis | |
14380 | @item @code{dico} (default: @var{dico}) | |
14381 | Package object of the GNU Dico dictionary server. | |
14382 | ||
a1b48465 LC |
14383 | @item @code{interfaces} (default: @var{'("localhost")}) |
14384 | This is the list of IP addresses and ports and possibly socket file | |
14385 | names to listen to (@pxref{Server Settings, @code{listen} directive,, | |
14386 | dico, GNU Dico Manual}). | |
14387 | ||
9af7ecd9 HY |
14388 | @item @code{handlers} (default: @var{'()}) |
14389 | List of @code{<dicod-handler>} objects denoting handlers (module instances). | |
14390 | ||
c3d38b2b SB |
14391 | @item @code{databases} (default: @var{(list %dicod-database:gcide)}) |
14392 | List of @code{<dicod-database>} objects denoting dictionaries to be served. | |
14393 | @end table | |
14394 | @end deftp | |
14395 | ||
9af7ecd9 HY |
14396 | @deftp {Data Type} dicod-handler |
14397 | Data type representing a dictionary handler (module instance). | |
c3d38b2b SB |
14398 | |
14399 | @table @asis | |
14400 | @item @code{name} | |
9af7ecd9 | 14401 | Name of the handler (module instance). |
c3d38b2b | 14402 | |
9af7ecd9 HY |
14403 | @item @code{module} (default: @var{#f}) |
14404 | Name of the dicod module of the handler (instance). If it is @code{#f}, | |
14405 | the module has the same name as the handler. | |
c3d38b2b SB |
14406 | (@pxref{Modules,,, dico, GNU Dico Manual}). |
14407 | ||
14408 | @item @code{options} | |
14409 | List of strings or gexps representing the arguments for the module handler | |
9af7ecd9 HY |
14410 | @end table |
14411 | @end deftp | |
14412 | ||
14413 | @deftp {Data Type} dicod-database | |
14414 | Data type representing a dictionary database. | |
14415 | ||
14416 | @table @asis | |
14417 | @item @code{name} | |
14418 | Name of the database, will be used in DICT commands. | |
14419 | ||
14420 | @item @code{handler} | |
14421 | Name of the dicod handler (module instance) used by this database | |
c3d38b2b | 14422 | (@pxref{Handlers,,, dico, GNU Dico Manual}). |
9af7ecd9 HY |
14423 | |
14424 | @item @code{complex?} (default: @var{#f}) | |
14425 | Whether the database configuration complex. The complex configuration | |
14426 | will need a corresponding @code{<dicod-handler>} object, otherwise not. | |
14427 | ||
14428 | @item @code{options} | |
14429 | List of strings or gexps representing the arguments for the database | |
14430 | (@pxref{Databases,,, dico, GNU Dico Manual}). | |
c3d38b2b SB |
14431 | @end table |
14432 | @end deftp | |
14433 | ||
14434 | @defvr {Scheme Variable} %dicod-database:gcide | |
14435 | A @code{<dicod-database>} object serving the GNU Collaborative International | |
9fc221b5 | 14436 | Dictionary of English using the @code{gcide} package. |
c3d38b2b | 14437 | @end defvr |
fe1a39d3 | 14438 | |
9af7ecd9 HY |
14439 | The following is an example @code{dicod-service} configuration. |
14440 | ||
14441 | @example | |
14442 | (dicod-service #:config | |
14443 | (dicod-configuration | |
14444 | (handlers (list (dicod-handler | |
14445 | (name "wordnet") | |
14446 | (module "dictorg") | |
14447 | (options | |
14448 | (list #~(string-append "dbdir=" #$wordnet)))))) | |
14449 | (databases (list (dicod-database | |
14450 | (name "wordnet") | |
14451 | (complex? #t) | |
14452 | (handler "wordnet") | |
14453 | (options '("database=wn"))) | |
14454 | %dicod-database:gcide)))) | |
14455 | @end example | |
14456 | ||
e01e2c6c | 14457 | @subsubsection Version Control |
14458 | ||
14459 | The @code{(gnu services version-control)} module provides the following services: | |
14460 | ||
14461 | @subsubheading Git daemon service | |
14462 | ||
14463 | @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)] | |
14464 | ||
14465 | Return a service that runs @command{git daemon}, a simple TCP server to | |
9fc221b5 | 14466 | expose repositories over the Git protocol for anonymous access. |
e01e2c6c | 14467 | |
14468 | The optional @var{config} argument should be a | |
14469 | @code{<git-daemon-configuration>} object, by default it allows read-only | |
14470 | access to exported@footnote{By creating the magic file | |
14471 | "git-daemon-export-ok" in the repository directory.} repositories under | |
14472 | @file{/srv/git}. | |
14473 | ||
14474 | @end deffn | |
14475 | ||
14476 | @deftp {Data Type} git-daemon-configuration | |
14477 | Data type representing the configuration for @code{git-daemon-service}. | |
14478 | ||
14479 | @table @asis | |
14480 | @item @code{package} (default: @var{git}) | |
14481 | Package object of the Git distributed version control system. | |
14482 | ||
14483 | @item @code{export-all?} (default: @var{#f}) | |
14484 | Whether to allow access for all Git repositories, even if they do not | |
14485 | have the @file{git-daemon-export-ok} file. | |
14486 | ||
14487 | @item @code{base-path} (default: @file{/srv/git}) | |
14488 | Whether to remap all the path requests as relative to the given path. | |
14489 | If you run git daemon with @var{(base-path "/srv/git")} on example.com, | |
14490 | then if you later try to pull @code{git://example.com/hello.git}, git | |
14491 | daemon will interpret the path as @code{/srv/git/hello.git}. | |
14492 | ||
14493 | @item @code{user-path} (default: @var{#f}) | |
14494 | Whether to allow @code{~user} notation to be used in requests. When | |
14495 | specified with empty string, requests to @code{git://host/~alice/foo} is | |
14496 | taken as a request to access @code{foo} repository in the home directory | |
14497 | of user @code{alice}. If @var{(user-path "path")} is specified, the | |
14498 | same request is taken as a request to access @code{path/foo} repository | |
14499 | in the home directory of user @code{alice}. | |
14500 | ||
14501 | @item @code{listen} (default: @var{'()}) | |
14502 | Whether to listen on specific IP addresses or hostnames, defaults to | |
14503 | all. | |
14504 | ||
14505 | @item @code{port} (default: @var{#f}) | |
14506 | Whether to listen on an alternative port, which defaults to 9418. | |
14507 | ||
14508 | @item @code{whitelist} (default: @var{'()}) | |
14509 | If not empty, only allow access to this list of directories. | |
14510 | ||
14511 | @item @code{extra-options} (default: @var{'()}) | |
14512 | Extra options will be passed to @code{git daemon}, please run | |
14513 | @command{man git-daemon} for more information. | |
14514 | ||
14515 | @end table | |
14516 | @end deftp | |
14517 | ||
0ae8c15a LC |
14518 | @node Setuid Programs |
14519 | @subsection Setuid Programs | |
14520 | ||
14521 | @cindex setuid programs | |
14522 | Some programs need to run with ``root'' privileges, even when they are | |
14523 | launched by unprivileged users. A notorious example is the | |
4d40227c LC |
14524 | @command{passwd} program, which users can run to change their |
14525 | password, and which needs to access the @file{/etc/passwd} and | |
0ae8c15a LC |
14526 | @file{/etc/shadow} files---something normally restricted to root, for |
14527 | obvious security reasons. To address that, these executables are | |
14528 | @dfn{setuid-root}, meaning that they always run with root privileges | |
14529 | (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual}, | |
f7e4ae7f | 14530 | for more info about the setuid mechanism.) |
0ae8c15a LC |
14531 | |
14532 | The store itself @emph{cannot} contain setuid programs: that would be a | |
14533 | security issue since any user on the system can write derivations that | |
14534 | populate the store (@pxref{The Store}). Thus, a different mechanism is | |
14535 | used: instead of changing the setuid bit directly on files that are in | |
14536 | the store, we let the system administrator @emph{declare} which programs | |
14537 | should be setuid root. | |
14538 | ||
14539 | The @code{setuid-programs} field of an @code{operating-system} | |
14540 | declaration contains a list of G-expressions denoting the names of | |
14541 | programs to be setuid-root (@pxref{Using the Configuration System}). | |
14542 | For instance, the @command{passwd} program, which is part of the Shadow | |
14543 | package, can be designated by this G-expression (@pxref{G-Expressions}): | |
14544 | ||
14545 | @example | |
14546 | #~(string-append #$shadow "/bin/passwd") | |
14547 | @end example | |
14548 | ||
14549 | A default set of setuid programs is defined by the | |
14550 | @code{%setuid-programs} variable of the @code{(gnu system)} module. | |
14551 | ||
14552 | @defvr {Scheme Variable} %setuid-programs | |
14553 | A list of G-expressions denoting common programs that are setuid-root. | |
14554 | ||
14555 | The list includes commands such as @command{passwd}, @command{ping}, | |
14556 | @command{su}, and @command{sudo}. | |
14557 | @end defvr | |
14558 | ||
14559 | Under the hood, the actual setuid programs are created in the | |
14560 | @file{/run/setuid-programs} directory at system activation time. The | |
14561 | files in this directory refer to the ``real'' binaries, which are in the | |
14562 | store. | |
14563 | ||
efb5e833 LC |
14564 | @node X.509 Certificates |
14565 | @subsection X.509 Certificates | |
14566 | ||
14567 | @cindex HTTPS, certificates | |
14568 | @cindex X.509 certificates | |
14569 | @cindex TLS | |
14570 | Web servers available over HTTPS (that is, HTTP over the transport-layer | |
14571 | security mechanism, TLS) send client programs an @dfn{X.509 certificate} | |
14572 | that the client can then use to @emph{authenticate} the server. To do | |
14573 | that, clients verify that the server's certificate is signed by a | |
14574 | so-called @dfn{certificate authority} (CA). But to verify the CA's | |
14575 | signature, clients must have first acquired the CA's certificate. | |
14576 | ||
14577 | Web browsers such as GNU@tie{}IceCat include their own set of CA | |
14578 | certificates, such that they are able to verify CA signatures | |
14579 | out-of-the-box. | |
14580 | ||
14581 | However, most other programs that can talk HTTPS---@command{wget}, | |
14582 | @command{git}, @command{w3m}, etc.---need to be told where CA | |
14583 | certificates can be found. | |
14584 | ||
14585 | @cindex @code{nss-certs} | |
14586 | In GuixSD, this is done by adding a package that provides certificates | |
14587 | to the @code{packages} field of the @code{operating-system} declaration | |
14588 | (@pxref{operating-system Reference}). GuixSD includes one such package, | |
14589 | @code{nss-certs}, which is a set of CA certificates provided as part of | |
14590 | Mozilla's Network Security Services. | |
14591 | ||
14592 | Note that it is @emph{not} part of @var{%base-packages}, so you need to | |
14593 | explicitly add it. The @file{/etc/ssl/certs} directory, which is where | |
14594 | most applications and libraries look for certificates by default, points | |
14595 | to the certificates installed globally. | |
14596 | ||
b3129f2b LC |
14597 | Unprivileged users, including users of Guix on a foreign distro, |
14598 | can also install their own certificate package in | |
efb5e833 LC |
14599 | their profile. A number of environment variables need to be defined so |
14600 | that applications and libraries know where to find them. Namely, the | |
14601 | OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE} | |
14602 | variables. Some applications add their own environment variables; for | |
14603 | instance, the Git version control system honors the certificate bundle | |
b3129f2b LC |
14604 | pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you |
14605 | would typically run something like: | |
efb5e833 | 14606 | |
b3129f2b LC |
14607 | @example |
14608 | $ guix package -i nss-certs | |
14609 | $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs" | |
14610 | $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt" | |
14611 | $ export GIT_SSL_CAINFO="$SSL_CERT_FILE" | |
14612 | @end example | |
efb5e833 | 14613 | |
996ed739 LC |
14614 | @node Name Service Switch |
14615 | @subsection Name Service Switch | |
14616 | ||
14617 | @cindex name service switch | |
14618 | @cindex NSS | |
14619 | The @code{(gnu system nss)} module provides bindings to the | |
1068f26b | 14620 | configuration file of the libc @dfn{name service switch} or @dfn{NSS} |
996ed739 LC |
14621 | (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference |
14622 | Manual}). In a nutshell, the NSS is a mechanism that allows libc to be | |
14623 | extended with new ``name'' lookup methods for system databases, which | |
14624 | includes host names, service names, user accounts, and more (@pxref{Name | |
14625 | Service Switch, System Databases and Name Service Switch,, libc, The GNU | |
14626 | C Library Reference Manual}). | |
14627 | ||
14628 | The NSS configuration specifies, for each system database, which lookup | |
14629 | method is to be used, and how the various methods are chained | |
14630 | together---for instance, under which circumstances NSS should try the | |
14631 | next method in the list. The NSS configuration is given in the | |
14632 | @code{name-service-switch} field of @code{operating-system} declarations | |
14633 | (@pxref{operating-system Reference, @code{name-service-switch}}). | |
14634 | ||
4c9050c6 LC |
14635 | @cindex nss-mdns |
14636 | @cindex .local, host name lookup | |
996ed739 | 14637 | As an example, the declaration below configures the NSS to use the |
4c9050c6 LC |
14638 | @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns} |
14639 | back-end}, which supports host name lookups over multicast DNS (mDNS) | |
14640 | for host names ending in @code{.local}: | |
996ed739 LC |
14641 | |
14642 | @example | |
14643 | (name-service-switch | |
14644 | (hosts (list %files ;first, check /etc/hosts | |
14645 | ||
14646 | ;; If the above did not succeed, try | |
14647 | ;; with 'mdns_minimal'. | |
14648 | (name-service | |
14649 | (name "mdns_minimal") | |
14650 | ||
14651 | ;; 'mdns_minimal' is authoritative for | |
14652 | ;; '.local'. When it returns "not found", | |
14653 | ;; no need to try the next methods. | |
14654 | (reaction (lookup-specification | |
14655 | (not-found => return)))) | |
14656 | ||
14657 | ;; Then fall back to DNS. | |
14658 | (name-service | |
14659 | (name "dns")) | |
14660 | ||
14661 | ;; Finally, try with the "full" 'mdns'. | |
14662 | (name-service | |
14663 | (name "mdns"))))) | |
14664 | @end example | |
14665 | ||
1068f26b AE |
14666 | Do not worry: the @code{%mdns-host-lookup-nss} variable (see below) |
14667 | contains this configuration, so you will not have to type it if all you | |
15137a29 LC |
14668 | want is to have @code{.local} host lookup working. |
14669 | ||
4c9050c6 LC |
14670 | Note that, in this case, in addition to setting the |
14671 | @code{name-service-switch} of the @code{operating-system} declaration, | |
cc9c1f39 LC |
14672 | you also need to use @code{avahi-service} (@pxref{Networking Services, |
14673 | @code{avahi-service}}), or @var{%desktop-services}, which includes it | |
14674 | (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible | |
14675 | to the name service cache daemon (@pxref{Base Services, | |
14676 | @code{nscd-service}}). | |
15137a29 LC |
14677 | |
14678 | For convenience, the following variables provide typical NSS | |
14679 | configurations. | |
14680 | ||
14681 | @defvr {Scheme Variable} %default-nss | |
14682 | This is the default name service switch configuration, a | |
14683 | @code{name-service-switch} object. | |
14684 | @end defvr | |
14685 | ||
14686 | @defvr {Scheme Variable} %mdns-host-lookup-nss | |
14687 | This is the name service switch configuration with support for host name | |
14688 | lookup over multicast DNS (mDNS) for host names ending in @code{.local}. | |
14689 | @end defvr | |
4c9050c6 | 14690 | |
996ed739 | 14691 | The reference for name service switch configuration is given below. It |
1068f26b | 14692 | is a direct mapping of the configuration file format of the C library , so |
996ed739 LC |
14693 | please refer to the C library manual for more information (@pxref{NSS |
14694 | Configuration File,,, libc, The GNU C Library Reference Manual}). | |
1068f26b | 14695 | Compared to the configuration file format of libc NSS, it has the advantage |
996ed739 | 14696 | not only of adding this warm parenthetic feel that we like, but also |
1068f26b | 14697 | static checks: you will know about syntax errors and typos as soon as you |
996ed739 LC |
14698 | run @command{guix system}. |
14699 | ||
996ed739 LC |
14700 | @deftp {Data Type} name-service-switch |
14701 | ||
14702 | This is the data type representation the configuration of libc's name | |
14703 | service switch (NSS). Each field below represents one of the supported | |
14704 | system databases. | |
14705 | ||
14706 | @table @code | |
14707 | @item aliases | |
14708 | @itemx ethers | |
14709 | @itemx group | |
14710 | @itemx gshadow | |
14711 | @itemx hosts | |
14712 | @itemx initgroups | |
14713 | @itemx netgroup | |
14714 | @itemx networks | |
14715 | @itemx password | |
14716 | @itemx public-key | |
14717 | @itemx rpc | |
14718 | @itemx services | |
14719 | @itemx shadow | |
14720 | The system databases handled by the NSS. Each of these fields must be a | |
1068f26b | 14721 | list of @code{<name-service>} objects (see below). |
996ed739 LC |
14722 | @end table |
14723 | @end deftp | |
14724 | ||
14725 | @deftp {Data Type} name-service | |
14726 | ||
14727 | This is the data type representing an actual name service and the | |
14728 | associated lookup action. | |
14729 | ||
14730 | @table @code | |
14731 | @item name | |
14732 | A string denoting the name service (@pxref{Services in the NSS | |
14733 | configuration,,, libc, The GNU C Library Reference Manual}). | |
14734 | ||
4aee6e60 LC |
14735 | Note that name services listed here must be visible to nscd. This is |
14736 | achieved by passing the @code{#:name-services} argument to | |
14737 | @code{nscd-service} the list of packages providing the needed name | |
14738 | services (@pxref{Base Services, @code{nscd-service}}). | |
14739 | ||
996ed739 LC |
14740 | @item reaction |
14741 | An action specified using the @code{lookup-specification} macro | |
14742 | (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library | |
14743 | Reference Manual}). For example: | |
14744 | ||
14745 | @example | |
14746 | (lookup-specification (unavailable => continue) | |
14747 | (success => return)) | |
14748 | @end example | |
14749 | @end table | |
14750 | @end deftp | |
0ae8c15a | 14751 | |
fd1b1fa2 LC |
14752 | @node Initial RAM Disk |
14753 | @subsection Initial RAM Disk | |
14754 | ||
e32171ee JD |
14755 | @cindex initrd |
14756 | @cindex initial RAM disk | |
fd1b1fa2 LC |
14757 | For bootstrapping purposes, the Linux-Libre kernel is passed an |
14758 | @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary | |
1068f26b | 14759 | root file system as well as an initialization script. The latter is |
fd1b1fa2 LC |
14760 | responsible for mounting the real root file system, and for loading any |
14761 | kernel modules that may be needed to achieve that. | |
14762 | ||
14763 | The @code{initrd} field of an @code{operating-system} declaration allows | |
14764 | you to specify which initrd you would like to use. The @code{(gnu | |
47bdc5a1 MO |
14765 | system linux-initrd)} module provides three ways to build an initrd: the |
14766 | high-level @code{base-initrd} procedure and the low-level | |
14767 | @code{raw-initrd} and @code{expression->initrd} procedures. | |
fd1b1fa2 LC |
14768 | |
14769 | The @code{base-initrd} procedure is intended to cover most common uses. | |
14770 | For example, if you want to add a bunch of kernel modules to be loaded | |
14771 | at boot time, you can define the @code{initrd} field of the operating | |
14772 | system declaration like this: | |
14773 | ||
14774 | @example | |
52ac153e | 14775 | (initrd (lambda (file-systems . rest) |
027981d6 LC |
14776 | ;; Create a standard initrd that has modules "foo.ko" |
14777 | ;; and "bar.ko", as well as their dependencies, in | |
14778 | ;; addition to the modules available by default. | |
52ac153e | 14779 | (apply base-initrd file-systems |
027981d6 | 14780 | #:extra-modules '("foo" "bar") |
52ac153e | 14781 | rest))) |
fd1b1fa2 LC |
14782 | @end example |
14783 | ||
52ac153e | 14784 | The @code{base-initrd} procedure also handles common use cases that |
1068f26b AE |
14785 | involves using the system as a QEMU guest, or as a ``live'' system with |
14786 | volatile root file system. | |
fd1b1fa2 | 14787 | |
47bdc5a1 MO |
14788 | The @code{base-initrd} procedure is built from @code{raw-initrd} procedure. |
14789 | Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level, | |
14790 | such as trying to guess which kernel modules and packages should be included | |
14791 | to the initrd. An example use of @code{raw-initrd} is when a user has | |
14792 | a custom Linux kernel configuration and default kernel modules included by | |
14793 | @code{base-initrd} are not available. | |
14794 | ||
14795 | The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd} | |
14796 | honors several options passed on the Linux kernel command line | |
14797 | (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the | |
4af2fafd | 14798 | @code{-append} option of QEMU), notably: |
e90cf6c1 LC |
14799 | |
14800 | @table @code | |
14801 | @item --load=@var{boot} | |
14802 | Tell the initial RAM disk to load @var{boot}, a file containing a Scheme | |
14803 | program, once it has mounted the root file system. | |
14804 | ||
14805 | GuixSD uses this option to yield control to a boot program that runs the | |
dd17bc38 | 14806 | service activation programs and then spawns the GNU@tie{}Shepherd, the |
e90cf6c1 LC |
14807 | initialization system. |
14808 | ||
14809 | @item --root=@var{root} | |
1068f26b | 14810 | Mount @var{root} as the root file system. @var{root} can be a |
e90cf6c1 LC |
14811 | device name like @code{/dev/sda1}, a partition label, or a partition |
14812 | UUID. | |
14813 | ||
14814 | @item --system=@var{system} | |
14815 | Have @file{/run/booted-system} and @file{/run/current-system} point to | |
14816 | @var{system}. | |
14817 | ||
14818 | @item modprobe.blacklist=@var{modules}@dots{} | |
14819 | @cindex module, black-listing | |
14820 | @cindex black list, of kernel modules | |
14821 | Instruct the initial RAM disk as well as the @command{modprobe} command | |
14822 | (from the kmod package) to refuse to load @var{modules}. @var{modules} | |
14823 | must be a comma-separated list of module names---e.g., | |
14824 | @code{usbkbd,9pnet}. | |
14825 | ||
14826 | @item --repl | |
14827 | Start a read-eval-print loop (REPL) from the initial RAM disk before it | |
14828 | tries to load kernel modules and to mount the root file system. Our | |
14829 | marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will | |
14830 | love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference | |
14831 | Manual}, for more information on Guile's REPL. | |
14832 | ||
14833 | @end table | |
14834 | ||
14835 | Now that you know all the features that initial RAM disks produced by | |
47bdc5a1 MO |
14836 | @code{base-initrd} and @code{raw-initrd} provide, |
14837 | here is how to use it and customize it further. | |
e90cf6c1 | 14838 | |
e32171ee JD |
14839 | @cindex initrd |
14840 | @cindex initial RAM disk | |
47bdc5a1 MO |
14841 | @deffn {Monadic Procedure} raw-initrd @var{file-systems} @ |
14842 | [#:linux-modules '()] [#:mapped-devices '()] @ | |
14843 | [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f] | |
14844 | Return a monadic derivation that builds a raw initrd. @var{file-systems} is | |
1068f26b | 14845 | a list of file systems to be mounted by the initrd, possibly in addition to |
fd1b1fa2 | 14846 | the root file system specified on the kernel command line via @code{--root}. |
47bdc5a1 | 14847 | @var{linux-modules} is a list of kernel modules to be loaded at boot time. |
52ac153e LC |
14848 | @var{mapped-devices} is a list of device mappings to realize before |
14849 | @var{file-systems} are mounted (@pxref{Mapped Devices}). | |
47bdc5a1 MO |
14850 | @var{helper-packages} is a list of packages to be copied in the initrd. It may |
14851 | include @code{e2fsck/static} or other packages needed by the initrd to check | |
14852 | root partition. | |
fd1b1fa2 LC |
14853 | |
14854 | When @var{qemu-networking?} is true, set up networking with the standard QEMU | |
1068f26b AE |
14855 | parameters. When @var{virtio?} is true, load additional modules so that the |
14856 | initrd can be used as a QEMU guest with para-virtualized I/O drivers. | |
fd1b1fa2 LC |
14857 | |
14858 | When @var{volatile-root?} is true, the root file system is writable but any changes | |
14859 | to it are lost. | |
47bdc5a1 MO |
14860 | @end deffn |
14861 | ||
14862 | @deffn {Monadic Procedure} base-initrd @var{file-systems} @ | |
14863 | [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@ | |
14864 | [#:virtio? #t] [#:extra-modules '()] | |
14865 | Return a monadic derivation that builds a generic initrd. @var{file-systems} is | |
14866 | a list of file systems to be mounted by the initrd like for @code{raw-initrd}. | |
14867 | @var{mapped-devices}, @var{qemu-networking?} and @var{volatile-root?} | |
14868 | also behaves as in @code{raw-initrd}. | |
14869 | ||
14870 | When @var{virtio?} is true, load additional modules so that the | |
14871 | initrd can be used as a QEMU guest with para-virtualized I/O drivers. | |
fd1b1fa2 LC |
14872 | |
14873 | The initrd is automatically populated with all the kernel modules necessary | |
14874 | for @var{file-systems} and for the given options. However, additional kernel | |
14875 | modules can be listed in @var{extra-modules}. They will be added to the initrd, and | |
14876 | loaded at boot time in the order in which they appear. | |
14877 | @end deffn | |
14878 | ||
14879 | Needless to say, the initrds we produce and use embed a | |
14880 | statically-linked Guile, and the initialization program is a Guile | |
14881 | program. That gives a lot of flexibility. The | |
14882 | @code{expression->initrd} procedure builds such an initrd, given the | |
14883 | program to run in that initrd. | |
14884 | ||
14885 | @deffn {Monadic Procedure} expression->initrd @var{exp} @ | |
4ee96a79 | 14886 | [#:guile %guile-static-stripped] [#:name "guile-initrd"] |
fd1b1fa2 LC |
14887 | Return a derivation that builds a Linux initrd (a gzipped cpio archive) |
14888 | containing @var{guile} and that evaluates @var{exp}, a G-expression, | |
df650fa8 LC |
14889 | upon booting. All the derivations referenced by @var{exp} are |
14890 | automatically copied to the initrd. | |
fd1b1fa2 LC |
14891 | @end deffn |
14892 | ||
88faf933 LC |
14893 | @node GRUB Configuration |
14894 | @subsection GRUB Configuration | |
14895 | ||
14896 | @cindex GRUB | |
14897 | @cindex boot loader | |
14898 | ||
14899 | The operating system uses GNU@tie{}GRUB as its boot loader | |
14900 | (@pxref{Overview, overview of GRUB,, grub, GNU GRUB Manual}). It is | |
1068f26b AE |
14901 | configured using a @code{grub-configuration} declaration. This data type |
14902 | is exported by the @code{(gnu system grub)} module and described below. | |
88faf933 LC |
14903 | |
14904 | @deftp {Data Type} grub-configuration | |
14905 | The type of a GRUB configuration declaration. | |
14906 | ||
14907 | @table @asis | |
14908 | ||
14909 | @item @code{device} | |
14910 | This is a string denoting the boot device. It must be a device name | |
14911 | understood by the @command{grub-install} command, such as | |
14912 | @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub, | |
14913 | GNU GRUB Manual}). | |
14914 | ||
14915 | @item @code{menu-entries} (default: @code{()}) | |
14916 | A possibly empty list of @code{menu-entry} objects (see below), denoting | |
14917 | entries to appear in the GRUB boot menu, in addition to the current | |
14918 | system entry and the entry pointing to previous system generations. | |
14919 | ||
14920 | @item @code{default-entry} (default: @code{0}) | |
1068f26b AE |
14921 | The index of the default boot menu entry. Index 0 is for the entry of the |
14922 | current system. | |
88faf933 LC |
14923 | |
14924 | @item @code{timeout} (default: @code{5}) | |
14925 | The number of seconds to wait for keyboard input before booting. Set to | |
14926 | 0 to boot immediately, and to -1 to wait indefinitely. | |
14927 | ||
14928 | @item @code{theme} (default: @var{%default-theme}) | |
14929 | The @code{grub-theme} object describing the theme to use. | |
9b06f503 LC |
14930 | |
14931 | @item @code{grub} (default: @code{grub}) | |
14932 | The GRUB package to use. | |
88faf933 LC |
14933 | @end table |
14934 | ||
14935 | @end deftp | |
14936 | ||
44d5f54e LC |
14937 | @cindex dual boot |
14938 | @cindex boot menu | |
88faf933 LC |
14939 | Should you want to list additional boot menu entries @i{via} the |
14940 | @code{menu-entries} field above, you will need to create them with the | |
44d5f54e LC |
14941 | @code{menu-entry} form. For example, imagine you want to be able to |
14942 | boot another distro (hard to imagine!), you can define a menu entry | |
14943 | along these lines: | |
14944 | ||
14945 | @example | |
14946 | (menu-entry | |
14947 | (label "The Other Distro") | |
14948 | (linux "/boot/old/vmlinux-2.6.32") | |
14949 | (linux-arguments '("root=/dev/sda2")) | |
14950 | (initrd "/boot/old/initrd")) | |
14951 | @end example | |
14952 | ||
14953 | Details below. | |
88faf933 LC |
14954 | |
14955 | @deftp {Data Type} menu-entry | |
14956 | The type of an entry in the GRUB boot menu. | |
14957 | ||
14958 | @table @asis | |
14959 | ||
14960 | @item @code{label} | |
35ed9306 | 14961 | The label to show in the menu---e.g., @code{"GNU"}. |
88faf933 LC |
14962 | |
14963 | @item @code{linux} | |
44d5f54e LC |
14964 | The Linux kernel image to boot, for example: |
14965 | ||
14966 | @example | |
14967 | (file-append linux-libre "/bzImage") | |
14968 | @end example | |
88faf933 | 14969 | |
1ef8b72a CM |
14970 | It is also possible to specify a device explicitly in the file path |
14971 | using GRUB's device naming convention (@pxref{Naming convention,,, grub, | |
14972 | GNU GRUB manual}), for example: | |
14973 | ||
14974 | @example | |
14975 | "(hd0,msdos1)/boot/vmlinuz" | |
14976 | @end example | |
14977 | ||
14978 | If the device is specified explicitly as above, then the @code{device} | |
14979 | field is ignored entirely. | |
14980 | ||
88faf933 LC |
14981 | @item @code{linux-arguments} (default: @code{()}) |
14982 | The list of extra Linux kernel command-line arguments---e.g., | |
14983 | @code{("console=ttyS0")}. | |
14984 | ||
14985 | @item @code{initrd} | |
14986 | A G-Expression or string denoting the file name of the initial RAM disk | |
14987 | to use (@pxref{G-Expressions}). | |
14988 | ||
1ef8b72a CM |
14989 | @item @code{device} (default: @code{#f}) |
14990 | The device where the kernel and initrd are to be found---i.e., the GRUB | |
14991 | @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}). | |
14992 | ||
14993 | This may be a file system label (a string), a file system UUID (a | |
14994 | bytevector, @pxref{File Systems}), or @code{#f}, in which case GRUB will | |
14995 | search the device containing the file specified by the @code{linux} | |
14996 | field (@pxref{search,,, grub, GNU GRUB manual}). It must @emph{not} be | |
14997 | an OS device name such as @file{/dev/sda1}. | |
14998 | ||
14999 | @item @code{device-mount-point} (default: @code{"/"}) | |
15000 | The mount point of the above device on the system. You probably do not | |
15001 | need to change the default value. GuixSD uses it to strip the prefix of | |
15002 | store file names for systems where @file{/gnu} or @file{/gnu/store} is | |
15003 | on a separate partition. | |
15004 | ||
88faf933 LC |
15005 | @end table |
15006 | @end deftp | |
15007 | ||
15008 | @c FIXME: Write documentation once it's stable. | |
15009 | Themes are created using the @code{grub-theme} form, which is not | |
15010 | documented yet. | |
15011 | ||
15012 | @defvr {Scheme Variable} %default-theme | |
15013 | This is the default GRUB theme used by the operating system, with a | |
15014 | fancy background image displaying the GNU and Guix logos. | |
15015 | @end defvr | |
15016 | ||
15017 | ||
cf4a9129 LC |
15018 | @node Invoking guix system |
15019 | @subsection Invoking @code{guix system} | |
0918e64a | 15020 | |
1068f26b | 15021 | Once you have written an operating system declaration as seen in the |
cf4a9129 LC |
15022 | previous section, it can be @dfn{instantiated} using the @command{guix |
15023 | system} command. The synopsis is: | |
4af2447e | 15024 | |
cf4a9129 LC |
15025 | @example |
15026 | guix system @var{options}@dots{} @var{action} @var{file} | |
15027 | @end example | |
4af2447e | 15028 | |
cf4a9129 LC |
15029 | @var{file} must be the name of a file containing an |
15030 | @code{operating-system} declaration. @var{action} specifies how the | |
a40424bd | 15031 | operating system is instantiated. Currently the following values are |
cf4a9129 | 15032 | supported: |
4af2447e | 15033 | |
cf4a9129 LC |
15034 | @table @code |
15035 | @item reconfigure | |
15036 | Build the operating system described in @var{file}, activate it, and | |
8074b330 CM |
15037 | switch to it@footnote{This action (and the related actions |
15038 | @code{switch-generation} and @code{roll-back}) are usable only on | |
15039 | systems already running GuixSD.}. | |
4af2447e | 15040 | |
cf4a9129 LC |
15041 | This effects all the configuration specified in @var{file}: user |
15042 | accounts, system services, global package list, setuid programs, etc. | |
240b57f0 LC |
15043 | The command starts system services specified in @var{file} that are not |
15044 | currently running; if a service is currently running, it does not | |
1068f26b | 15045 | attempt to upgrade it since this would not be possible without stopping it |
240b57f0 | 15046 | first. |
4af2447e | 15047 | |
067a2e2d CM |
15048 | This command creates a new generation whose number is one greater than |
15049 | the current generation (as reported by @command{guix system | |
15050 | list-generations}). If that generation already exists, it will be | |
15051 | overwritten. This behavior mirrors that of @command{guix package} | |
15052 | (@pxref{Invoking guix package}). | |
15053 | ||
cf4a9129 LC |
15054 | It also adds a GRUB menu entry for the new OS configuration, and moves |
15055 | entries for older configurations to a submenu---unless | |
15056 | @option{--no-grub} is passed. | |
4af2447e | 15057 | |
240b57f0 | 15058 | @quotation Note |
bf2479c7 LC |
15059 | @c The paragraph below refers to the problem discussed at |
15060 | @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>. | |
15061 | It is highly recommended to run @command{guix pull} once before you run | |
15062 | @command{guix system reconfigure} for the first time (@pxref{Invoking | |
15063 | guix pull}). Failing to do that you would see an older version of Guix | |
15064 | once @command{reconfigure} has completed. | |
240b57f0 | 15065 | @end quotation |
bf2479c7 | 15066 | |
8074b330 | 15067 | @item switch-generation |
e32171ee | 15068 | @cindex generations |
8074b330 CM |
15069 | Switch to an existing system generation. This action atomically |
15070 | switches the system profile to the specified system generation. It also | |
15071 | rearranges the system's existing GRUB menu entries. It makes the menu | |
15072 | entry for the specified system generation the default, and it moves the | |
15073 | entries for the other generations to a submenu. The next time the | |
15074 | system boots, it will use the specified system generation. | |
15075 | ||
15076 | The target generation can be specified explicitly by its generation | |
15077 | number. For example, the following invocation would switch to system | |
15078 | generation 7: | |
15079 | ||
15080 | @example | |
15081 | guix system switch-generation 7 | |
15082 | @end example | |
15083 | ||
15084 | The target generation can also be specified relative to the current | |
15085 | generation with the form @code{+N} or @code{-N}, where @code{+3} means | |
15086 | ``3 generations ahead of the current generation,'' and @code{-1} means | |
15087 | ``1 generation prior to the current generation.'' When specifying a | |
15088 | negative value such as @code{-1}, you must precede it with @code{--} to | |
15089 | prevent it from being parsed as an option. For example: | |
15090 | ||
15091 | @example | |
15092 | guix system switch-generation -- -1 | |
15093 | @end example | |
15094 | ||
15095 | Currently, the effect of invoking this action is @emph{only} to switch | |
15096 | the system profile to an existing generation and rearrange the GRUB menu | |
15097 | entries. To actually start using the target system generation, you must | |
15098 | reboot after running this action. In the future, it will be updated to | |
15099 | do the same things as @command{reconfigure}, like activating and | |
15100 | deactivating services. | |
15101 | ||
15102 | This action will fail if the specified generation does not exist. | |
15103 | ||
15104 | @item roll-back | |
e32171ee | 15105 | @cindex rolling back |
8074b330 CM |
15106 | Switch to the preceding system generation. The next time the system |
15107 | boots, it will use the preceding system generation. This is the inverse | |
15108 | of @command{reconfigure}, and it is exactly the same as invoking | |
15109 | @command{switch-generation} with an argument of @code{-1}. | |
15110 | ||
15111 | Currently, as with @command{switch-generation}, you must reboot after | |
15112 | running this action to actually start using the preceding system | |
15113 | generation. | |
15114 | ||
cf4a9129 | 15115 | @item build |
1068f26b | 15116 | Build the derivation of the operating system, which includes all the |
cf4a9129 LC |
15117 | configuration files and programs needed to boot and run the system. |
15118 | This action does not actually install anything. | |
113daf62 | 15119 | |
cf4a9129 LC |
15120 | @item init |
15121 | Populate the given directory with all the files necessary to run the | |
15122 | operating system specified in @var{file}. This is useful for first-time | |
4705641f | 15123 | installations of GuixSD. For instance: |
113daf62 LC |
15124 | |
15125 | @example | |
cf4a9129 | 15126 | guix system init my-os-config.scm /mnt |
113daf62 LC |
15127 | @end example |
15128 | ||
cf4a9129 LC |
15129 | copies to @file{/mnt} all the store items required by the configuration |
15130 | specified in @file{my-os-config.scm}. This includes configuration | |
15131 | files, packages, and so on. It also creates other essential files | |
15132 | needed for the system to operate correctly---e.g., the @file{/etc}, | |
15133 | @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file. | |
113daf62 | 15134 | |
cf4a9129 LC |
15135 | This command also installs GRUB on the device specified in |
15136 | @file{my-os-config}, unless the @option{--no-grub} option was passed. | |
113daf62 | 15137 | |
cf4a9129 LC |
15138 | @item vm |
15139 | @cindex virtual machine | |
0276f697 | 15140 | @cindex VM |
f535dcbe | 15141 | @anchor{guix system vm} |
1068f26b | 15142 | Build a virtual machine that contains the operating system declared in |
cf4a9129 | 15143 | @var{file}, and return a script to run that virtual machine (VM). |
1068f26b | 15144 | Arguments given to the script are passed to QEMU. |
113daf62 | 15145 | |
cf4a9129 | 15146 | The VM shares its store with the host system. |
113daf62 | 15147 | |
0276f697 LC |
15148 | Additional file systems can be shared between the host and the VM using |
15149 | the @code{--share} and @code{--expose} command-line options: the former | |
15150 | specifies a directory to be shared with write access, while the latter | |
15151 | provides read-only access to the shared directory. | |
15152 | ||
15153 | The example below creates a VM in which the user's home directory is | |
15154 | accessible read-only, and where the @file{/exchange} directory is a | |
1068f26b | 15155 | read-write mapping of @file{$HOME/tmp} on the host: |
0276f697 LC |
15156 | |
15157 | @example | |
15158 | guix system vm my-config.scm \ | |
15159 | --expose=$HOME --share=$HOME/tmp=/exchange | |
15160 | @end example | |
15161 | ||
6aa260af LC |
15162 | On GNU/Linux, the default is to boot directly to the kernel; this has |
15163 | the advantage of requiring only a very tiny root disk image since the | |
1068f26b | 15164 | store of the host can then be mounted. |
6aa260af LC |
15165 | |
15166 | The @code{--full-boot} option forces a complete boot sequence, starting | |
15167 | with the bootloader. This requires more disk space since a root image | |
15168 | containing at least the kernel, initrd, and bootloader data files must | |
15169 | be created. The @code{--image-size} option can be used to specify the | |
1068f26b | 15170 | size of the image. |
ab11f0be | 15171 | |
cf4a9129 LC |
15172 | @item vm-image |
15173 | @itemx disk-image | |
15174 | Return a virtual machine or disk image of the operating system declared | |
15175 | in @var{file} that stands alone. Use the @option{--image-size} option | |
15176 | to specify the size of the image. | |
113daf62 | 15177 | |
cf4a9129 | 15178 | When using @code{vm-image}, the returned image is in qcow2 format, which |
97d76250 LF |
15179 | the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM}, |
15180 | for more information on how to run the image in a virtual machine. | |
113daf62 | 15181 | |
cf4a9129 LC |
15182 | When using @code{disk-image}, a raw disk image is produced; it can be |
15183 | copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is | |
1068f26b | 15184 | the device corresponding to a USB stick, one can copy the image to it |
cf4a9129 | 15185 | using the following command: |
113daf62 | 15186 | |
cf4a9129 LC |
15187 | @example |
15188 | # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc | |
15189 | @end example | |
113daf62 | 15190 | |
1c8a81b1 DT |
15191 | @item container |
15192 | Return a script to run the operating system declared in @var{file} | |
15193 | within a container. Containers are a set of lightweight isolation | |
15194 | mechanisms provided by the kernel Linux-libre. Containers are | |
15195 | substantially less resource-demanding than full virtual machines since | |
15196 | the kernel, shared objects, and other resources can be shared with the | |
15197 | host system; this also means they provide thinner isolation. | |
15198 | ||
15199 | Currently, the script must be run as root in order to support more than | |
15200 | a single user and group. The container shares its store with the host | |
15201 | system. | |
15202 | ||
15203 | As with the @code{vm} action (@pxref{guix system vm}), additional file | |
15204 | systems to be shared between the host and container can be specified | |
15205 | using the @option{--share} and @option{--expose} options: | |
15206 | ||
15207 | @example | |
15208 | guix system container my-config.scm \ | |
15209 | --expose=$HOME --share=$HOME/tmp=/exchange | |
15210 | @end example | |
15211 | ||
0f252e26 | 15212 | @quotation Note |
cfd35b4e | 15213 | This option requires Linux-libre 3.19 or newer. |
0f252e26 DT |
15214 | @end quotation |
15215 | ||
cf4a9129 | 15216 | @end table |
113daf62 | 15217 | |
ccd7158d LC |
15218 | @var{options} can contain any of the common build options (@pxref{Common |
15219 | Build Options}). In addition, @var{options} can contain one of the | |
15220 | following: | |
113daf62 | 15221 | |
cf4a9129 LC |
15222 | @table @option |
15223 | @item --system=@var{system} | |
15224 | @itemx -s @var{system} | |
1068f26b | 15225 | Attempt to build for @var{system} instead of the host system type. |
cf4a9129 | 15226 | This works as per @command{guix build} (@pxref{Invoking guix build}). |
113daf62 | 15227 | |
f3f427c2 LC |
15228 | @item --derivation |
15229 | @itemx -d | |
15230 | Return the derivation file name of the given operating system without | |
15231 | building anything. | |
15232 | ||
cf4a9129 LC |
15233 | @item --image-size=@var{size} |
15234 | For the @code{vm-image} and @code{disk-image} actions, create an image | |
15235 | of the given @var{size}. @var{size} may be a number of bytes, or it may | |
4a44d7bb LC |
15236 | include a unit as a suffix (@pxref{Block size, size specifications,, |
15237 | coreutils, GNU Coreutils}). | |
db030303 LC |
15238 | |
15239 | @item --on-error=@var{strategy} | |
15240 | Apply @var{strategy} when an error occurs when reading @var{file}. | |
15241 | @var{strategy} may be one of the following: | |
15242 | ||
15243 | @table @code | |
15244 | @item nothing-special | |
15245 | Report the error concisely and exit. This is the default strategy. | |
15246 | ||
15247 | @item backtrace | |
15248 | Likewise, but also display a backtrace. | |
15249 | ||
15250 | @item debug | |
15251 | Report the error and enter Guile's debugger. From there, you can run | |
15252 | commands such as @code{,bt} to get a backtrace, @code{,locals} to | |
1068f26b AE |
15253 | display local variable values, and more generally inspect the state of the |
15254 | program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for | |
db030303 LC |
15255 | a list of available debugging commands. |
15256 | @end table | |
113daf62 | 15257 | @end table |
113daf62 | 15258 | |
eca69fc0 LC |
15259 | @quotation Note |
15260 | All the actions above, except @code{build} and @code{init}, | |
15261 | can use KVM support in the Linux-libre kernel. Specifically, if the | |
15262 | machine has hardware virtualization support, the corresponding | |
cf4a9129 | 15263 | KVM kernel module should be loaded, and the @file{/dev/kvm} device node |
1068f26b | 15264 | must exist and be readable and writable by the user and by the |
eca69fc0 LC |
15265 | build users of the daemon (@pxref{Build Environment Setup}). |
15266 | @end quotation | |
8451a568 | 15267 | |
65797bff LC |
15268 | Once you have built, configured, re-configured, and re-re-configured |
15269 | your GuixSD installation, you may find it useful to list the operating | |
15270 | system generations available on disk---and that you can choose from the | |
15271 | GRUB boot menu: | |
15272 | ||
15273 | @table @code | |
15274 | ||
15275 | @item list-generations | |
15276 | List a summary of each generation of the operating system available on | |
15277 | disk, in a human-readable way. This is similar to the | |
15278 | @option{--list-generations} option of @command{guix package} | |
15279 | (@pxref{Invoking guix package}). | |
15280 | ||
15281 | Optionally, one can specify a pattern, with the same syntax that is used | |
15282 | in @command{guix package --list-generations}, to restrict the list of | |
15283 | generations displayed. For instance, the following command displays | |
1068f26b | 15284 | generations that are up to 10 days old: |
65797bff LC |
15285 | |
15286 | @example | |
15287 | $ guix system list-generations 10d | |
15288 | @end example | |
15289 | ||
15290 | @end table | |
15291 | ||
d6c3267a LC |
15292 | The @command{guix system} command has even more to offer! The following |
15293 | sub-commands allow you to visualize how your system services relate to | |
15294 | each other: | |
15295 | ||
15296 | @anchor{system-extension-graph} | |
15297 | @table @code | |
15298 | ||
15299 | @item extension-graph | |
15300 | Emit in Dot/Graphviz format to standard output the @dfn{service | |
15301 | extension graph} of the operating system defined in @var{file} | |
15302 | (@pxref{Service Composition}, for more information on service | |
15303 | extensions.) | |
15304 | ||
15305 | The command: | |
15306 | ||
15307 | @example | |
15308 | $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf | |
15309 | @end example | |
15310 | ||
15311 | produces a PDF file showing the extension relations among services. | |
15312 | ||
710fa231 AK |
15313 | @anchor{system-shepherd-graph} |
15314 | @item shepherd-graph | |
6f305ea5 | 15315 | Emit in Dot/Graphviz format to standard output the @dfn{dependency |
dd17bc38 AK |
15316 | graph} of shepherd services of the operating system defined in |
15317 | @var{file}. @xref{Shepherd Services}, for more information and for an | |
15318 | example graph. | |
6f305ea5 | 15319 | |
d6c3267a LC |
15320 | @end table |
15321 | ||
97d76250 | 15322 | @node Running GuixSD in a VM |
70ac09a5 | 15323 | @subsection Running GuixSD in a Virtual Machine |
97d76250 | 15324 | |
e32171ee | 15325 | @cindex virtual machine |
97d76250 LF |
15326 | One way to run GuixSD in a virtual machine (VM) is to build a GuixSD |
15327 | virtual machine image using @command{guix system vm-image} | |
15328 | (@pxref{Invoking guix system}). The returned image is in qcow2 format, | |
15329 | which the @uref{http://qemu.org/, QEMU emulator} can efficiently use. | |
15330 | ||
e32171ee | 15331 | @cindex QEMU |
97d76250 LF |
15332 | To run the image in QEMU, copy it out of the store (@pxref{The Store}) |
15333 | and give yourself permission to write to the copy. When invoking QEMU, | |
15334 | you must choose a system emulator that is suitable for your hardware | |
15335 | platform. Here is a minimal QEMU invocation that will boot the result | |
15336 | of @command{guix system vm-image} on x86_64 hardware: | |
15337 | ||
15338 | @example | |
15339 | $ qemu-system-x86_64 \ | |
15340 | -net user -net nic,model=virtio \ | |
15341 | -enable-kvm -m 256 /tmp/qemu-image | |
15342 | @end example | |
15343 | ||
15344 | Here is what each of these options means: | |
15345 | ||
15346 | @table @code | |
15347 | @item qemu-system-x86_64 | |
15348 | This specifies the hardware platform to emulate. This should match the | |
15349 | host. | |
15350 | ||
15351 | @item -net user | |
15352 | Enable the unprivileged user-mode network stack. The guest OS can | |
15353 | access the host but not vice versa. This is the simplest way to get the | |
58806e6f | 15354 | guest OS online. |
97d76250 LF |
15355 | |
15356 | @item -net nic,model=virtio | |
1068f26b | 15357 | You must create a network interface of a given model. If you do not |
97d76250 LF |
15358 | create a NIC, the boot will fail. Assuming your hardware platform is |
15359 | x86_64, you can get a list of available NIC models by running | |
15360 | @command{qemu-system-x86_64 -net nic,model=help}. | |
15361 | ||
15362 | @item -enable-kvm | |
15363 | If your system has hardware virtualization extensions, enabling the | |
1068f26b | 15364 | virtual machine support (KVM) of the Linux kernel will make things run |
97d76250 LF |
15365 | faster. |
15366 | ||
15367 | @item -m 256 | |
15368 | RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB, | |
7414de0a | 15369 | which may be insufficient for some operations. |
97d76250 LF |
15370 | |
15371 | @item /tmp/qemu-image | |
15372 | The file name of the qcow2 image. | |
15373 | @end table | |
d6c3267a | 15374 | |
9fc221b5 | 15375 | The default @command{run-vm.sh} script that is returned by an invocation of |
3ddc50db DC |
15376 | @command{guix system vm} does not add a @command{-net user} flag by default. |
15377 | To get network access from within the vm add the @code{(dhcp-client-service)} | |
15378 | to your system definition and start the VM using | |
15379 | @command{`guix system vm config.scm` -net user}. An important caveat of using | |
15380 | @command{-net user} for networking is that @command{ping} will not work, because | |
15381 | it uses the ICMP protocol. You'll have to use a different command to check for | |
15382 | network connectivity, like for example @command{curl}. | |
15383 | ||
15384 | @subsubsection Connecting Through SSH | |
15385 | ||
e32171ee JD |
15386 | @cindex SSH |
15387 | @cindex SSH server | |
3ddc50db DC |
15388 | To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)} |
15389 | or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently | |
15390 | boot unsupervised. It requires you to type some characters to initialize the | |
15391 | randomness generator. In addition you need to forward the SSH port, 22 by | |
15392 | default, to the host. You can do this with | |
15393 | ||
15394 | @example | |
15395 | `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22 | |
15396 | @end example | |
15397 | ||
15398 | To connect to the VM you can run | |
15399 | ||
15400 | @example | |
15401 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 | |
15402 | @end example | |
15403 | ||
15404 | The @command{-p} tells @command{ssh} the port you want to connect to. | |
15405 | @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining | |
15406 | every time you modify your @command{config.scm} file and the | |
15407 | @command{-o StrictHostKeyChecking=no} prevents you from having to allow a | |
15408 | connection to an unknown host every time you connect. | |
15409 | ||
15410 | @subsubsection Using @command{virt-viewer} with Spice | |
15411 | ||
15412 | As an alternative to the default @command{qemu} graphical client you can | |
15413 | use the @command{remote-viewer} from the @command{virt-viewer} package. To | |
15414 | connect pass the @command{-spice port=5930,disable-ticketing} flag to | |
15415 | @command{qemu}. See previous section for further information on how to do this. | |
15416 | ||
15417 | Spice also allows you to do some nice stuff like share your clipboard with your | |
15418 | VM. To enable that you'll also have to pass the following flags to @command{qemu}: | |
15419 | ||
15420 | @example | |
15421 | -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5 | |
15422 | -chardev spicevmc,name=vdagent,id=vdagent | |
15423 | -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent, | |
15424 | name=com.redhat.spice.0 | |
15425 | @end example | |
15426 | ||
15427 | You'll also need to add the @pxref{Miscellaneous Services, Spice service}. | |
15428 | ||
cf4a9129 LC |
15429 | @node Defining Services |
15430 | @subsection Defining Services | |
8451a568 | 15431 | |
eb524192 | 15432 | The previous sections show the available services and how one can combine |
0adfe95a LC |
15433 | them in an @code{operating-system} declaration. But how do we define |
15434 | them in the first place? And what is a service anyway? | |
8451a568 | 15435 | |
0adfe95a LC |
15436 | @menu |
15437 | * Service Composition:: The model for composing services. | |
15438 | * Service Types and Services:: Types and services. | |
15439 | * Service Reference:: API reference. | |
dd17bc38 | 15440 | * Shepherd Services:: A particular type of service. |
0adfe95a LC |
15441 | @end menu |
15442 | ||
15443 | @node Service Composition | |
15444 | @subsubsection Service Composition | |
15445 | ||
15446 | @cindex services | |
15447 | @cindex daemons | |
15448 | Here we define a @dfn{service} as, broadly, something that extends the | |
1068f26b | 15449 | functionality of the operating system. Often a service is a process---a |
0adfe95a LC |
15450 | @dfn{daemon}---started when the system boots: a secure shell server, a |
15451 | Web server, the Guix build daemon, etc. Sometimes a service is a daemon | |
15452 | whose execution can be triggered by another daemon---e.g., an FTP server | |
15453 | started by @command{inetd} or a D-Bus service activated by | |
15454 | @command{dbus-daemon}. Occasionally, a service does not map to a | |
15455 | daemon. For instance, the ``account'' service collects user accounts | |
15456 | and makes sure they exist when the system runs; the ``udev'' service | |
15457 | collects device management rules and makes them available to the eudev | |
1068f26b AE |
15458 | daemon; the @file{/etc} service populates the @file{/etc} directory |
15459 | of the system. | |
0adfe95a | 15460 | |
d6c3267a | 15461 | @cindex service extensions |
0adfe95a | 15462 | GuixSD services are connected by @dfn{extensions}. For instance, the |
1068f26b | 15463 | secure shell service @emph{extends} the Shepherd---the GuixSD |
dd17bc38 AK |
15464 | initialization system, running as PID@tie{}1---by giving it the command |
15465 | lines to start and stop the secure shell daemon (@pxref{Networking | |
15466 | Services, @code{lsh-service}}); the UPower service extends the D-Bus | |
15467 | service by passing it its @file{.service} specification, and extends the | |
15468 | udev service by passing it device management rules (@pxref{Desktop | |
15469 | Services, @code{upower-service}}); the Guix daemon service extends the | |
15470 | Shepherd by passing it the command lines to start and stop the daemon, | |
15471 | and extends the account service by passing it a list of required build | |
15472 | user accounts (@pxref{Base Services}). | |
0adfe95a LC |
15473 | |
15474 | All in all, services and their ``extends'' relations form a directed | |
15475 | acyclic graph (DAG). If we represent services as boxes and extensions | |
15476 | as arrows, a typical system might provide something like this: | |
15477 | ||
15478 | @image{images/service-graph,,5in,Typical service extension graph.} | |
15479 | ||
d62e201c LC |
15480 | @cindex system service |
15481 | At the bottom, we see the @dfn{system service}, which produces the | |
15482 | directory containing everything to run and boot the system, as returned | |
15483 | by the @command{guix system build} command. @xref{Service Reference}, | |
15484 | to learn about the other service types shown here. | |
d6c3267a LC |
15485 | @xref{system-extension-graph, the @command{guix system extension-graph} |
15486 | command}, for information on how to generate this representation for a | |
15487 | particular operating system definition. | |
0adfe95a LC |
15488 | |
15489 | @cindex service types | |
15490 | Technically, developers can define @dfn{service types} to express these | |
15491 | relations. There can be any number of services of a given type on the | |
15492 | system---for instance, a system running two instances of the GNU secure | |
15493 | shell server (lsh) has two instances of @var{lsh-service-type}, with | |
15494 | different parameters. | |
15495 | ||
15496 | The following section describes the programming interface for service | |
15497 | types and services. | |
15498 | ||
15499 | @node Service Types and Services | |
15500 | @subsubsection Service Types and Services | |
15501 | ||
15502 | A @dfn{service type} is a node in the DAG described above. Let us start | |
15503 | with a simple example, the service type for the Guix build daemon | |
15504 | (@pxref{Invoking guix-daemon}): | |
15505 | ||
15506 | @example | |
15507 | (define guix-service-type | |
15508 | (service-type | |
15509 | (name 'guix) | |
15510 | (extensions | |
d4053c71 | 15511 | (list (service-extension shepherd-root-service-type guix-shepherd-service) |
0adfe95a LC |
15512 | (service-extension account-service-type guix-accounts) |
15513 | (service-extension activation-service-type guix-activation))))) | |
15514 | @end example | |
8451a568 | 15515 | |
cf4a9129 | 15516 | @noindent |
1068f26b | 15517 | It defines two things: |
0adfe95a LC |
15518 | |
15519 | @enumerate | |
15520 | @item | |
15521 | A name, whose sole purpose is to make inspection and debugging easier. | |
15522 | ||
15523 | @item | |
15524 | A list of @dfn{service extensions}, where each extension designates the | |
1068f26b AE |
15525 | target service type and a procedure that, given the parameters of the |
15526 | service, returns a list of objects to extend the service of that type. | |
0adfe95a LC |
15527 | |
15528 | Every service type has at least one service extension. The only | |
15529 | exception is the @dfn{boot service type}, which is the ultimate service. | |
15530 | @end enumerate | |
15531 | ||
15532 | In this example, @var{guix-service-type} extends three services: | |
15533 | ||
15534 | @table @var | |
d4053c71 AK |
15535 | @item shepherd-root-service-type |
15536 | The @var{guix-shepherd-service} procedure defines how the Shepherd | |
15537 | service is extended. Namely, it returns a @code{<shepherd-service>} | |
15538 | object that defines how @command{guix-daemon} is started and stopped | |
15539 | (@pxref{Shepherd Services}). | |
0adfe95a LC |
15540 | |
15541 | @item account-service-type | |
15542 | This extension for this service is computed by @var{guix-accounts}, | |
15543 | which returns a list of @code{user-group} and @code{user-account} | |
15544 | objects representing the build user accounts (@pxref{Invoking | |
15545 | guix-daemon}). | |
15546 | ||
15547 | @item activation-service-type | |
15548 | Here @var{guix-activation} is a procedure that returns a gexp, which is | |
15549 | a code snippet to run at ``activation time''---e.g., when the service is | |
15550 | booted. | |
15551 | @end table | |
15552 | ||
15553 | A service of this type is instantiated like this: | |
15554 | ||
15555 | @example | |
15556 | (service guix-service-type | |
15557 | (guix-configuration | |
15558 | (build-accounts 5) | |
15559 | (use-substitutes? #f))) | |
15560 | @end example | |
15561 | ||
15562 | The second argument to the @code{service} form is a value representing | |
15563 | the parameters of this specific service instance. | |
15564 | @xref{guix-configuration-type, @code{guix-configuration}}, for | |
15565 | information about the @code{guix-configuration} data type. | |
15566 | ||
15567 | @var{guix-service-type} is quite simple because it extends other | |
15568 | services but is not extensible itself. | |
15569 | ||
15570 | @c @subsubsubsection Extensible Service Types | |
15571 | ||
15572 | The service type for an @emph{extensible} service looks like this: | |
15573 | ||
15574 | @example | |
15575 | (define udev-service-type | |
15576 | (service-type (name 'udev) | |
15577 | (extensions | |
d4053c71 AK |
15578 | (list (service-extension shepherd-root-service-type |
15579 | udev-shepherd-service))) | |
0adfe95a LC |
15580 | |
15581 | (compose concatenate) ;concatenate the list of rules | |
15582 | (extend (lambda (config rules) | |
15583 | (match config | |
15584 | (($ <udev-configuration> udev initial-rules) | |
15585 | (udev-configuration | |
15586 | (udev udev) ;the udev package to use | |
15587 | (rules (append initial-rules rules))))))))) | |
15588 | @end example | |
15589 | ||
15590 | This is the service type for the | |
15591 | @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device | |
15592 | management daemon}. Compared to the previous example, in addition to an | |
d4053c71 | 15593 | extension of @var{shepherd-root-service-type}, we see two new fields: |
0adfe95a LC |
15594 | |
15595 | @table @code | |
15596 | @item compose | |
15597 | This is the procedure to @dfn{compose} the list of extensions to | |
15598 | services of this type. | |
15599 | ||
15600 | Services can extend the udev service by passing it lists of rules; we | |
15601 | compose those extensions simply by concatenating them. | |
15602 | ||
15603 | @item extend | |
1068f26b | 15604 | This procedure defines how the value of the service is @dfn{extended} with |
0adfe95a LC |
15605 | the composition of the extensions. |
15606 | ||
15607 | Udev extensions are composed into a list of rules, but the udev service | |
15608 | value is itself a @code{<udev-configuration>} record. So here, we | |
a40424bd | 15609 | extend that record by appending the list of rules it contains to the |
0adfe95a LC |
15610 | list of contributed rules. |
15611 | @end table | |
15612 | ||
15613 | There can be only one instance of an extensible service type such as | |
15614 | @var{udev-service-type}. If there were more, the | |
15615 | @code{service-extension} specifications would be ambiguous. | |
15616 | ||
15617 | Still here? The next section provides a reference of the programming | |
15618 | interface for services. | |
15619 | ||
15620 | @node Service Reference | |
15621 | @subsubsection Service Reference | |
15622 | ||
15623 | We have seen an overview of service types (@pxref{Service Types and | |
15624 | Services}). This section provides a reference on how to manipulate | |
15625 | services and service types. This interface is provided by the | |
15626 | @code{(gnu services)} module. | |
15627 | ||
15628 | @deffn {Scheme Procedure} service @var{type} @var{value} | |
15629 | Return a new service of @var{type}, a @code{<service-type>} object (see | |
15630 | below.) @var{value} can be any object; it represents the parameters of | |
15631 | this particular service instance. | |
15632 | @end deffn | |
15633 | ||
15634 | @deffn {Scheme Procedure} service? @var{obj} | |
15635 | Return true if @var{obj} is a service. | |
15636 | @end deffn | |
8451a568 | 15637 | |
0adfe95a LC |
15638 | @deffn {Scheme Procedure} service-kind @var{service} |
15639 | Return the type of @var{service}---i.e., a @code{<service-type>} object. | |
15640 | @end deffn | |
15641 | ||
15642 | @deffn {Scheme Procedure} service-parameters @var{service} | |
15643 | Return the value associated with @var{service}. It represents its | |
15644 | parameters. | |
15645 | @end deffn | |
15646 | ||
15647 | Here is an example of how a service is created and manipulated: | |
15648 | ||
15649 | @example | |
15650 | (define s | |
15651 | (service nginx-service-type | |
15652 | (nginx-configuration | |
15653 | (nginx nginx) | |
15654 | (log-directory log-directory) | |
15655 | (run-directory run-directory) | |
15656 | (file config-file)))) | |
15657 | ||
15658 | (service? s) | |
15659 | @result{} #t | |
15660 | ||
15661 | (eq? (service-kind s) nginx-service-type) | |
15662 | @result{} #t | |
15663 | @end example | |
15664 | ||
cd6f6c22 LC |
15665 | The @code{modify-services} form provides a handy way to change the |
15666 | parameters of some of the services of a list such as | |
4d343a14 | 15667 | @var{%base-services} (@pxref{Base Services, @code{%base-services}}). It |
7414de0a | 15668 | evaluates to a list of services. Of course, you could always use |
4d343a14 CM |
15669 | standard list combinators such as @code{map} and @code{fold} to do that |
15670 | (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual}); | |
15671 | @code{modify-services} simply provides a more concise form for this | |
15672 | common pattern. | |
cd6f6c22 LC |
15673 | |
15674 | @deffn {Scheme Syntax} modify-services @var{services} @ | |
15675 | (@var{type} @var{variable} => @var{body}) @dots{} | |
15676 | ||
15677 | Modify the services listed in @var{services} according to the given | |
15678 | clauses. Each clause has the form: | |
15679 | ||
15680 | @example | |
15681 | (@var{type} @var{variable} => @var{body}) | |
15682 | @end example | |
15683 | ||
4d343a14 CM |
15684 | where @var{type} is a service type---e.g., |
15685 | @code{guix-service-type}---and @var{variable} is an identifier that is | |
15686 | bound within the @var{body} to the service parameters---e.g., a | |
15687 | @code{guix-configuration} instance---of the original service of that | |
15688 | @var{type}. | |
cd6f6c22 | 15689 | |
4d343a14 CM |
15690 | The @var{body} should evaluate to the new service parameters, which will |
15691 | be used to configure the new service. This new service will replace the | |
15692 | original in the resulting list. Because a service's service parameters | |
7414de0a | 15693 | are created using @code{define-record-type*}, you can write a succinct |
4d343a14 CM |
15694 | @var{body} that evaluates to the new service parameters by using the |
15695 | @code{inherit} feature that @code{define-record-type*} provides. | |
15696 | ||
b53daad0 | 15697 | @xref{Using the Configuration System}, for example usage. |
cd6f6c22 | 15698 | |
cd6f6c22 LC |
15699 | @end deffn |
15700 | ||
15701 | Next comes the programming interface for service types. This is | |
15702 | something you want to know when writing new service definitions, but not | |
15703 | necessarily when simply looking for ways to customize your | |
15704 | @code{operating-system} declaration. | |
15705 | ||
0adfe95a LC |
15706 | @deftp {Data Type} service-type |
15707 | @cindex service type | |
15708 | This is the representation of a @dfn{service type} (@pxref{Service Types | |
15709 | and Services}). | |
15710 | ||
15711 | @table @asis | |
15712 | @item @code{name} | |
15713 | This is a symbol, used only to simplify inspection and debugging. | |
15714 | ||
15715 | @item @code{extensions} | |
1068f26b | 15716 | A non-empty list of @code{<service-extension>} objects (see below). |
0adfe95a LC |
15717 | |
15718 | @item @code{compose} (default: @code{#f}) | |
15719 | If this is @code{#f}, then the service type denotes services that cannot | |
15720 | be extended---i.e., services that do not receive ``values'' from other | |
15721 | services. | |
15722 | ||
15723 | Otherwise, it must be a one-argument procedure. The procedure is called | |
15724 | by @code{fold-services} and is passed a list of values collected from | |
15725 | extensions. It must return a value that is a valid parameter value for | |
15726 | the service instance. | |
15727 | ||
15728 | @item @code{extend} (default: @code{#f}) | |
15729 | If this is @code{#f}, services of this type cannot be extended. | |
15730 | ||
15731 | Otherwise, it must be a two-argument procedure: @code{fold-services} | |
1068f26b | 15732 | calls it, passing it the initial value of the service as the first argument |
0adfe95a LC |
15733 | and the result of applying @code{compose} to the extension values as the |
15734 | second argument. | |
15735 | @end table | |
15736 | ||
15737 | @xref{Service Types and Services}, for examples. | |
15738 | @end deftp | |
15739 | ||
15740 | @deffn {Scheme Procedure} service-extension @var{target-type} @ | |
15741 | @var{compute} | |
15742 | Return a new extension for services of type @var{target-type}. | |
15743 | @var{compute} must be a one-argument procedure: @code{fold-services} | |
15744 | calls it, passing it the value associated with the service that provides | |
15745 | the extension; it must return a valid value for the target service. | |
15746 | @end deffn | |
15747 | ||
15748 | @deffn {Scheme Procedure} service-extension? @var{obj} | |
15749 | Return true if @var{obj} is a service extension. | |
15750 | @end deffn | |
15751 | ||
71654dfd LC |
15752 | Occasionally, you might want to simply extend an existing service. This |
15753 | involves creating a new service type and specifying the extension of | |
15754 | interest, which can be verbose; the @code{simple-service} procedure | |
15755 | provides a shorthand for this. | |
15756 | ||
15757 | @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value} | |
15758 | Return a service that extends @var{target} with @var{value}. This works | |
15759 | by creating a singleton service type @var{name}, of which the returned | |
15760 | service is an instance. | |
15761 | ||
15762 | For example, this extends mcron (@pxref{Scheduled Job Execution}) with | |
15763 | an additional job: | |
15764 | ||
15765 | @example | |
15766 | (simple-service 'my-mcron-job mcron-service-type | |
15767 | #~(job '(next-hour (3)) "guix gc -F 2G")) | |
15768 | @end example | |
15769 | @end deffn | |
15770 | ||
0adfe95a LC |
15771 | At the core of the service abstraction lies the @code{fold-services} |
15772 | procedure, which is responsible for ``compiling'' a list of services | |
d62e201c LC |
15773 | down to a single directory that contains everything needed to boot and |
15774 | run the system---the directory shown by the @command{guix system build} | |
15775 | command (@pxref{Invoking guix system}). In essence, it propagates | |
15776 | service extensions down the service graph, updating each node parameters | |
15777 | on the way, until it reaches the root node. | |
0adfe95a LC |
15778 | |
15779 | @deffn {Scheme Procedure} fold-services @var{services} @ | |
d62e201c | 15780 | [#:target-type @var{system-service-type}] |
0adfe95a LC |
15781 | Fold @var{services} by propagating their extensions down to the root of |
15782 | type @var{target-type}; return the root service adjusted accordingly. | |
15783 | @end deffn | |
15784 | ||
15785 | Lastly, the @code{(gnu services)} module also defines several essential | |
15786 | service types, some of which are listed below. | |
15787 | ||
d62e201c LC |
15788 | @defvr {Scheme Variable} system-service-type |
15789 | This is the root of the service graph. It produces the system directory | |
15790 | as returned by the @command{guix system build} command. | |
15791 | @end defvr | |
15792 | ||
0adfe95a | 15793 | @defvr {Scheme Variable} boot-service-type |
d62e201c LC |
15794 | The type of the ``boot service'', which produces the @dfn{boot script}. |
15795 | The boot script is what the initial RAM disk runs when booting. | |
0adfe95a LC |
15796 | @end defvr |
15797 | ||
15798 | @defvr {Scheme Variable} etc-service-type | |
15799 | The type of the @file{/etc} service. This service can be extended by | |
15800 | passing it name/file tuples such as: | |
15801 | ||
15802 | @example | |
15803 | (list `("issue" ,(plain-file "issue" "Welcome!\n"))) | |
15804 | @end example | |
15805 | ||
15806 | In this example, the effect would be to add an @file{/etc/issue} file | |
15807 | pointing to the given file. | |
15808 | @end defvr | |
15809 | ||
15810 | @defvr {Scheme Variable} setuid-program-service-type | |
15811 | Type for the ``setuid-program service''. This service collects lists of | |
15812 | executable file names, passed as gexps, and adds them to the set of | |
15813 | setuid-root programs on the system (@pxref{Setuid Programs}). | |
15814 | @end defvr | |
15815 | ||
af4c3fd5 LC |
15816 | @defvr {Scheme Variable} profile-service-type |
15817 | Type of the service that populates the @dfn{system profile}---i.e., the | |
15818 | programs under @file{/run/current-system/profile}. Other services can | |
15819 | extend it by passing it lists of packages to add to the system profile. | |
15820 | @end defvr | |
15821 | ||
0adfe95a | 15822 | |
dd17bc38 AK |
15823 | @node Shepherd Services |
15824 | @subsubsection Shepherd Services | |
0adfe95a | 15825 | |
e32171ee | 15826 | @cindex shepherd services |
0adfe95a LC |
15827 | @cindex PID 1 |
15828 | @cindex init system | |
a40424bd CM |
15829 | The @code{(gnu services shepherd)} module provides a way to define |
15830 | services managed by the GNU@tie{}Shepherd, which is the GuixSD | |
15831 | initialization system---the first process that is started when the | |
1068f26b AE |
15832 | system boots, also known as PID@tie{}1 |
15833 | (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}). | |
6f305ea5 | 15834 | |
dd17bc38 AK |
15835 | Services in the Shepherd can depend on each other. For instance, the |
15836 | SSH daemon may need to be started after the syslog daemon has been | |
15837 | started, which in turn can only happen once all the file systems have | |
15838 | been mounted. The simple operating system defined earlier (@pxref{Using | |
15839 | the Configuration System}) results in a service graph like this: | |
6f305ea5 | 15840 | |
710fa231 | 15841 | @image{images/shepherd-graph,,5in,Typical shepherd service graph.} |
6f305ea5 LC |
15842 | |
15843 | You can actually generate such a graph for any operating system | |
710fa231 AK |
15844 | definition using the @command{guix system shepherd-graph} command |
15845 | (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}). | |
6f305ea5 | 15846 | |
d4053c71 AK |
15847 | The @var{%shepherd-root-service} is a service object representing |
15848 | PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended | |
15849 | by passing it lists of @code{<shepherd-service>} objects. | |
0adfe95a | 15850 | |
d4053c71 | 15851 | @deftp {Data Type} shepherd-service |
dd17bc38 | 15852 | The data type representing a service managed by the Shepherd. |
0adfe95a LC |
15853 | |
15854 | @table @asis | |
15855 | @item @code{provision} | |
15856 | This is a list of symbols denoting what the service provides. | |
15857 | ||
dd17bc38 AK |
15858 | These are the names that may be passed to @command{herd start}, |
15859 | @command{herd status}, and similar commands (@pxref{Invoking herd,,, | |
15860 | shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the | |
15861 | @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details. | |
0adfe95a LC |
15862 | |
15863 | @item @code{requirements} (default: @code{'()}) | |
dd17bc38 | 15864 | List of symbols denoting the Shepherd services this one depends on. |
0adfe95a LC |
15865 | |
15866 | @item @code{respawn?} (default: @code{#t}) | |
15867 | Whether to restart the service when it stops, for instance when the | |
15868 | underlying process dies. | |
15869 | ||
15870 | @item @code{start} | |
15871 | @itemx @code{stop} (default: @code{#~(const #f)}) | |
dd17bc38 AK |
15872 | The @code{start} and @code{stop} fields refer to the Shepherd's |
15873 | facilities to start and stop processes (@pxref{Service De- and | |
15874 | Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as | |
15875 | G-expressions that get expanded in the Shepherd configuration file | |
15876 | (@pxref{G-Expressions}). | |
0adfe95a LC |
15877 | |
15878 | @item @code{documentation} | |
15879 | A documentation string, as shown when running: | |
15880 | ||
15881 | @example | |
dd17bc38 | 15882 | herd doc @var{service-name} |
0adfe95a LC |
15883 | @end example |
15884 | ||
15885 | where @var{service-name} is one of the symbols in @var{provision} | |
dd17bc38 | 15886 | (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}). |
fae685b9 LC |
15887 | |
15888 | @item @code{modules} (default: @var{%default-modules}) | |
15889 | This is the list of modules that must be in scope when @code{start} and | |
15890 | @code{stop} are evaluated. | |
15891 | ||
0adfe95a LC |
15892 | @end table |
15893 | @end deftp | |
15894 | ||
d4053c71 | 15895 | @defvr {Scheme Variable} shepherd-root-service-type |
dd17bc38 | 15896 | The service type for the Shepherd ``root service''---i.e., PID@tie{}1. |
0adfe95a LC |
15897 | |
15898 | This is the service type that extensions target when they want to create | |
dd17bc38 | 15899 | shepherd services (@pxref{Service Types and Services}, for an example). |
d4053c71 | 15900 | Each extension must pass a list of @code{<shepherd-service>}. |
0adfe95a LC |
15901 | @end defvr |
15902 | ||
d4053c71 | 15903 | @defvr {Scheme Variable} %shepherd-root-service |
0adfe95a LC |
15904 | This service represents PID@tie{}1. |
15905 | @end defvr | |
8451a568 | 15906 | |
8451a568 | 15907 | |
cf4a9129 LC |
15908 | @node Installing Debugging Files |
15909 | @section Installing Debugging Files | |
8451a568 | 15910 | |
cf4a9129 LC |
15911 | @cindex debugging files |
15912 | Program binaries, as produced by the GCC compilers for instance, are | |
15913 | typically written in the ELF format, with a section containing | |
15914 | @dfn{debugging information}. Debugging information is what allows the | |
15915 | debugger, GDB, to map binary code to source code; it is required to | |
15916 | debug a compiled program in good conditions. | |
8451a568 | 15917 | |
cf4a9129 LC |
15918 | The problem with debugging information is that is takes up a fair amount |
15919 | of disk space. For example, debugging information for the GNU C Library | |
15920 | weighs in at more than 60 MiB. Thus, as a user, keeping all the | |
15921 | debugging info of all the installed programs is usually not an option. | |
15922 | Yet, space savings should not come at the cost of an impediment to | |
15923 | debugging---especially in the GNU system, which should make it easier | |
15924 | for users to exert their computing freedom (@pxref{GNU Distribution}). | |
8451a568 | 15925 | |
cf4a9129 LC |
15926 | Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a |
15927 | mechanism that allows users to get the best of both worlds: debugging | |
15928 | information can be stripped from the binaries and stored in separate | |
15929 | files. GDB is then able to load debugging information from those files, | |
15930 | when they are available (@pxref{Separate Debug Files,,, gdb, Debugging | |
15931 | with GDB}). | |
8451a568 | 15932 | |
cf4a9129 LC |
15933 | The GNU distribution takes advantage of this by storing debugging |
15934 | information in the @code{lib/debug} sub-directory of a separate package | |
15935 | output unimaginatively called @code{debug} (@pxref{Packages with | |
15936 | Multiple Outputs}). Users can choose to install the @code{debug} output | |
15937 | of a package when they need it. For instance, the following command | |
15938 | installs the debugging information for the GNU C Library and for GNU | |
15939 | Guile: | |
8451a568 LC |
15940 | |
15941 | @example | |
cf4a9129 | 15942 | guix package -i glibc:debug guile:debug |
8451a568 LC |
15943 | @end example |
15944 | ||
cf4a9129 LC |
15945 | GDB must then be told to look for debug files in the user's profile, by |
15946 | setting the @code{debug-file-directory} variable (consider setting it | |
15947 | from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with | |
15948 | GDB}): | |
8451a568 | 15949 | |
cf4a9129 LC |
15950 | @example |
15951 | (gdb) set debug-file-directory ~/.guix-profile/lib/debug | |
15952 | @end example | |
8451a568 | 15953 | |
cf4a9129 LC |
15954 | From there on, GDB will pick up debugging information from the |
15955 | @code{.debug} files under @file{~/.guix-profile/lib/debug}. | |
8451a568 | 15956 | |
cf4a9129 LC |
15957 | In addition, you will most likely want GDB to be able to show the source |
15958 | code being debugged. To do that, you will have to unpack the source | |
15959 | code of the package of interest (obtained with @code{guix build | |
15960 | --source}, @pxref{Invoking guix build}), and to point GDB to that source | |
15961 | directory using the @code{directory} command (@pxref{Source Path, | |
15962 | @code{directory},, gdb, Debugging with GDB}). | |
8451a568 | 15963 | |
cf4a9129 LC |
15964 | @c XXX: keep me up-to-date |
15965 | The @code{debug} output mechanism in Guix is implemented by the | |
15966 | @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is | |
1068f26b AE |
15967 | opt-in---debugging information is available only for the packages |
15968 | with definitions explicitly declaring a @code{debug} output. This may be | |
15969 | changed to opt-out in the future if our build farm servers can handle | |
cf4a9129 LC |
15970 | the load. To check whether a package has a @code{debug} output, use |
15971 | @command{guix package --list-available} (@pxref{Invoking guix package}). | |
8451a568 | 15972 | |
8451a568 | 15973 | |
05962f29 LC |
15974 | @node Security Updates |
15975 | @section Security Updates | |
15976 | ||
09866b39 LC |
15977 | @cindex security updates |
15978 | @cindex security vulnerabilities | |
15979 | Occasionally, important security vulnerabilities are discovered in software | |
15980 | packages and must be patched. Guix developers try hard to keep track of | |
15981 | known vulnerabilities and to apply fixes as soon as possible in the | |
15982 | @code{master} branch of Guix (we do not yet provide a ``stable'' branch | |
15983 | containing only security updates.) The @command{guix lint} tool helps | |
15984 | developers find out about vulnerable versions of software packages in the | |
15985 | distribution: | |
15986 | ||
15987 | @smallexample | |
15988 | $ guix lint -c cve | |
15989 | gnu/packages/base.scm:652:2: glibc-2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547 | |
15990 | gnu/packages/gcc.scm:334:2: gcc-4.9.3: probably vulnerable to CVE-2015-5276 | |
15991 | gnu/packages/image.scm:312:2: openjpeg-2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924 | |
15992 | @dots{} | |
15993 | @end smallexample | |
15994 | ||
15995 | @xref{Invoking guix lint}, for more information. | |
15996 | ||
843858b8 | 15997 | @quotation Note |
09866b39 LC |
15998 | As of version @value{VERSION}, the feature described below is considered |
15999 | ``beta''. | |
843858b8 | 16000 | @end quotation |
05962f29 | 16001 | |
09866b39 | 16002 | Guix follows a functional |
05962f29 LC |
16003 | package management discipline (@pxref{Introduction}), which implies |
16004 | that, when a package is changed, @emph{every package that depends on it} | |
16005 | must be rebuilt. This can significantly slow down the deployment of | |
16006 | fixes in core packages such as libc or Bash, since basically the whole | |
16007 | distribution would need to be rebuilt. Using pre-built binaries helps | |
16008 | (@pxref{Substitutes}), but deployment may still take more time than | |
16009 | desired. | |
16010 | ||
16011 | @cindex grafts | |
1068f26b | 16012 | To address this, Guix implements @dfn{grafts}, a mechanism that allows |
05962f29 LC |
16013 | for fast deployment of critical updates without the costs associated |
16014 | with a whole-distribution rebuild. The idea is to rebuild only the | |
16015 | package that needs to be patched, and then to ``graft'' it onto packages | |
16016 | explicitly installed by the user and that were previously referring to | |
16017 | the original package. The cost of grafting is typically very low, and | |
16018 | order of magnitudes lower than a full rebuild of the dependency chain. | |
16019 | ||
16020 | @cindex replacements of packages, for grafts | |
16021 | For instance, suppose a security update needs to be applied to Bash. | |
16022 | Guix developers will provide a package definition for the ``fixed'' | |
16023 | Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining | |
16024 | Packages}). Then, the original package definition is augmented with a | |
16025 | @code{replacement} field pointing to the package containing the bug fix: | |
16026 | ||
16027 | @example | |
16028 | (define bash | |
16029 | (package | |
16030 | (name "bash") | |
16031 | ;; @dots{} | |
16032 | (replacement bash-fixed))) | |
16033 | @end example | |
16034 | ||
c22a1324 LC |
16035 | From there on, any package depending directly or indirectly on Bash---as |
16036 | reported by @command{guix gc --requisites} (@pxref{Invoking guix | |
16037 | gc})---that is installed is automatically ``rewritten'' to refer to | |
05962f29 | 16038 | @var{bash-fixed} instead of @var{bash}. This grafting process takes |
1068f26b | 16039 | time proportional to the size of the package, usually less than a |
c22a1324 LC |
16040 | minute for an ``average'' package on a recent machine. Grafting is |
16041 | recursive: when an indirect dependency requires grafting, then grafting | |
16042 | ``propagates'' up to the package that the user is installing. | |
05962f29 | 16043 | |
57bdd79e LC |
16044 | Currently, the length of the name and version of the graft and that of |
16045 | the package it replaces (@var{bash-fixed} and @var{bash} in the example | |
16046 | above) must be equal. This restriction mostly comes from the fact that | |
16047 | grafting works by patching files, including binary files, directly. | |
05962f29 LC |
16048 | Other restrictions may apply: for instance, when adding a graft to a |
16049 | package providing a shared library, the original shared library and its | |
16050 | replacement must have the same @code{SONAME} and be binary-compatible. | |
16051 | ||
59a4dd50 LC |
16052 | The @option{--no-grafts} command-line option allows you to forcefully |
16053 | avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}). | |
16054 | Thus, the command: | |
16055 | ||
16056 | @example | |
16057 | guix build bash --no-grafts | |
16058 | @end example | |
16059 | ||
16060 | @noindent | |
16061 | returns the store file name of the original Bash, whereas: | |
16062 | ||
16063 | @example | |
16064 | guix build bash | |
16065 | @end example | |
16066 | ||
16067 | @noindent | |
16068 | returns the store file name of the ``fixed'', replacement Bash. This | |
16069 | allows you to distinguish between the two variants of Bash. | |
16070 | ||
16071 | To verify which Bash your whole profile refers to, you can run | |
16072 | (@pxref{Invoking guix gc}): | |
16073 | ||
16074 | @example | |
16075 | guix gc -R `readlink -f ~/.guix-profile` | grep bash | |
16076 | @end example | |
16077 | ||
16078 | @noindent | |
16079 | @dots{} and compare the store file names that you get with those above. | |
16080 | Likewise for a complete GuixSD system generation: | |
16081 | ||
16082 | @example | |
16083 | guix gc -R `guix system build my-config.scm` | grep bash | |
16084 | @end example | |
16085 | ||
16086 | Lastly, to check which Bash running processes are using, you can use the | |
16087 | @command{lsof} command: | |
16088 | ||
16089 | @example | |
16090 | lsof | grep /gnu/store/.*bash | |
16091 | @end example | |
16092 | ||
05962f29 | 16093 | |
cf4a9129 LC |
16094 | @node Package Modules |
16095 | @section Package Modules | |
8451a568 | 16096 | |
cf4a9129 LC |
16097 | From a programming viewpoint, the package definitions of the |
16098 | GNU distribution are provided by Guile modules in the @code{(gnu packages | |
16099 | @dots{})} name space@footnote{Note that packages under the @code{(gnu | |
16100 | packages @dots{})} module name space are not necessarily ``GNU | |
16101 | packages''. This module naming scheme follows the usual Guile module | |
16102 | naming convention: @code{gnu} means that these modules are distributed | |
16103 | as part of the GNU system, and @code{packages} identifies modules that | |
16104 | define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile | |
16105 | Reference Manual}). For instance, the @code{(gnu packages emacs)} | |
16106 | module exports a variable named @code{emacs}, which is bound to a | |
16107 | @code{<package>} object (@pxref{Defining Packages}). | |
113daf62 | 16108 | |
300868ba | 16109 | The @code{(gnu packages @dots{})} module name space is |
cf4a9129 LC |
16110 | automatically scanned for packages by the command-line tools. For |
16111 | instance, when running @code{guix package -i emacs}, all the @code{(gnu | |
16112 | packages @dots{})} modules are scanned until one that exports a package | |
16113 | object whose name is @code{emacs} is found. This package search | |
16114 | facility is implemented in the @code{(gnu packages)} module. | |
113daf62 | 16115 | |
300868ba | 16116 | @cindex customization, of packages |
8689901f | 16117 | @cindex package module search path |
cf4a9129 | 16118 | Users can store package definitions in modules with different |
60142854 | 16119 | names---e.g., @code{(my-packages emacs)}@footnote{Note that the file |
c95ded7e LC |
16120 | name and module name must match. For instance, the @code{(my-packages |
16121 | emacs)} module must be stored in a @file{my-packages/emacs.scm} file | |
16122 | relative to the load path specified with @option{--load-path} or | |
16123 | @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,, | |
16124 | guile, GNU Guile Reference Manual}, for details.}. These package definitions | |
1068f26b AE |
16125 | will not be visible by default. Users can invoke commands such as |
16126 | @command{guix package} and @command{guix build} with the | |
c95ded7e LC |
16127 | @code{-e} option so that they know where to find the package. Better |
16128 | yet, they can use the | |
300868ba | 16129 | @code{-L} option of these commands to make those modules visible |
8689901f LC |
16130 | (@pxref{Invoking guix build, @code{--load-path}}), or define the |
16131 | @code{GUIX_PACKAGE_PATH} environment variable. This environment | |
16132 | variable makes it easy to extend or customize the distribution and is | |
16133 | honored by all the user interfaces. | |
16134 | ||
16135 | @defvr {Environment Variable} GUIX_PACKAGE_PATH | |
1068f26b AE |
16136 | This is a colon-separated list of directories to search for additional |
16137 | package modules. Directories listed in this variable take precedence | |
16138 | over the own modules of the distribution. | |
8689901f | 16139 | @end defvr |
ef5dd60a | 16140 | |
cf4a9129 LC |
16141 | The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}: |
16142 | each package is built based solely on other packages in the | |
16143 | distribution. The root of this dependency graph is a small set of | |
16144 | @dfn{bootstrap binaries}, provided by the @code{(gnu packages | |
16145 | bootstrap)} module. For more information on bootstrapping, | |
081145cf | 16146 | @pxref{Bootstrapping}. |
ef5dd60a | 16147 | |
cf4a9129 LC |
16148 | @node Packaging Guidelines |
16149 | @section Packaging Guidelines | |
ef5dd60a | 16150 | |
e32171ee | 16151 | @cindex packages, creating |
cf4a9129 LC |
16152 | The GNU distribution is nascent and may well lack some of your favorite |
16153 | packages. This section describes how you can help make the distribution | |
16154 | grow. @xref{Contributing}, for additional information on how you can | |
16155 | help. | |
ef5dd60a | 16156 | |
cf4a9129 LC |
16157 | Free software packages are usually distributed in the form of |
16158 | @dfn{source code tarballs}---typically @file{tar.gz} files that contain | |
16159 | all the source files. Adding a package to the distribution means | |
16160 | essentially two things: adding a @dfn{recipe} that describes how to | |
16161 | build the package, including a list of other packages required to build | |
f97c9175 | 16162 | it, and adding @dfn{package metadata} along with that recipe, such as a |
cf4a9129 | 16163 | description and licensing information. |
ef5dd60a | 16164 | |
cf4a9129 LC |
16165 | In Guix all this information is embodied in @dfn{package definitions}. |
16166 | Package definitions provide a high-level view of the package. They are | |
16167 | written using the syntax of the Scheme programming language; in fact, | |
16168 | for each package we define a variable bound to the package definition, | |
16169 | and export that variable from a module (@pxref{Package Modules}). | |
16170 | However, in-depth Scheme knowledge is @emph{not} a prerequisite for | |
16171 | creating packages. For more information on package definitions, | |
081145cf | 16172 | @pxref{Defining Packages}. |
ef5dd60a | 16173 | |
cf4a9129 LC |
16174 | Once a package definition is in place, stored in a file in the Guix |
16175 | source tree, it can be tested using the @command{guix build} command | |
16176 | (@pxref{Invoking guix build}). For example, assuming the new package is | |
c71979f4 LC |
16177 | called @code{gnew}, you may run this command from the Guix build tree |
16178 | (@pxref{Running Guix Before It Is Installed}): | |
ef5dd60a LC |
16179 | |
16180 | @example | |
cf4a9129 | 16181 | ./pre-inst-env guix build gnew --keep-failed |
ef5dd60a | 16182 | @end example |
ef5dd60a | 16183 | |
cf4a9129 LC |
16184 | Using @code{--keep-failed} makes it easier to debug build failures since |
16185 | it provides access to the failed build tree. Another useful | |
16186 | command-line option when debugging is @code{--log-file}, to access the | |
16187 | build log. | |
ef5dd60a | 16188 | |
cf4a9129 LC |
16189 | If the package is unknown to the @command{guix} command, it may be that |
16190 | the source file contains a syntax error, or lacks a @code{define-public} | |
16191 | clause to export the package variable. To figure it out, you may load | |
16192 | the module from Guile to get more information about the actual error: | |
ef5dd60a | 16193 | |
cf4a9129 LC |
16194 | @example |
16195 | ./pre-inst-env guile -c '(use-modules (gnu packages gnew))' | |
16196 | @end example | |
ef5dd60a | 16197 | |
cf4a9129 LC |
16198 | Once your package builds correctly, please send us a patch |
16199 | (@pxref{Contributing}). Well, if you need help, we will be happy to | |
16200 | help you too. Once the patch is committed in the Guix repository, the | |
16201 | new package automatically gets built on the supported platforms by | |
2b1cee21 | 16202 | @url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration |
cf4a9129 | 16203 | system}. |
ef5dd60a | 16204 | |
cf4a9129 LC |
16205 | @cindex substituter |
16206 | Users can obtain the new package definition simply by running | |
16207 | @command{guix pull} (@pxref{Invoking guix pull}). When | |
16208 | @code{hydra.gnu.org} is done building the package, installing the | |
16209 | package automatically downloads binaries from there | |
16210 | (@pxref{Substitutes}). The only place where human intervention is | |
16211 | needed is to review and apply the patch. | |
ef5dd60a | 16212 | |
ef5dd60a | 16213 | |
cf4a9129 | 16214 | @menu |
ec0339cd LC |
16215 | * Software Freedom:: What may go into the distribution. |
16216 | * Package Naming:: What's in a name? | |
16217 | * Version Numbers:: When the name is not enough. | |
cbd02397 | 16218 | * Synopses and Descriptions:: Helping users find the right package. |
ec0339cd LC |
16219 | * Python Modules:: Taming the snake. |
16220 | * Perl Modules:: Little pearls. | |
e1c963bf | 16221 | * Java Packages:: Coffee break. |
ec0339cd | 16222 | * Fonts:: Fond of fonts. |
cf4a9129 | 16223 | @end menu |
ef5dd60a | 16224 | |
cf4a9129 LC |
16225 | @node Software Freedom |
16226 | @subsection Software Freedom | |
ef5dd60a | 16227 | |
cf4a9129 | 16228 | @c Adapted from http://www.gnu.org/philosophy/philosophy.html. |
e32171ee | 16229 | @cindex free software |
cf4a9129 LC |
16230 | The GNU operating system has been developed so that users can have |
16231 | freedom in their computing. GNU is @dfn{free software}, meaning that | |
16232 | users have the @url{http://www.gnu.org/philosophy/free-sw.html,four | |
16233 | essential freedoms}: to run the program, to study and change the program | |
16234 | in source code form, to redistribute exact copies, and to distribute | |
16235 | modified versions. Packages found in the GNU distribution provide only | |
16236 | software that conveys these four freedoms. | |
c11a6eb1 | 16237 | |
cf4a9129 LC |
16238 | In addition, the GNU distribution follow the |
16239 | @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free | |
16240 | software distribution guidelines}. Among other things, these guidelines | |
16241 | reject non-free firmware, recommendations of non-free software, and | |
16242 | discuss ways to deal with trademarks and patents. | |
ef5dd60a | 16243 | |
1068f26b AE |
16244 | Some otherwise free upstream package sources contain a small and optional |
16245 | subset that violates the above guidelines, for instance because this subset | |
16246 | is itself non-free code. When that happens, the offending items are removed | |
16247 | with appropriate patches or code snippets in the @code{origin} form of the | |
16248 | package (@pxref{Defining Packages}). This way, @code{guix | |
cf4a9129 LC |
16249 | build --source} returns the ``freed'' source rather than the unmodified |
16250 | upstream source. | |
ef5dd60a | 16251 | |
ef5dd60a | 16252 | |
cf4a9129 LC |
16253 | @node Package Naming |
16254 | @subsection Package Naming | |
ef5dd60a | 16255 | |
e32171ee | 16256 | @cindex package name |
cf4a9129 LC |
16257 | A package has actually two names associated with it: |
16258 | First, there is the name of the @emph{Scheme variable}, the one following | |
16259 | @code{define-public}. By this name, the package can be made known in the | |
16260 | Scheme code, for instance as input to another package. Second, there is | |
16261 | the string in the @code{name} field of a package definition. This name | |
16262 | is used by package management commands such as | |
16263 | @command{guix package} and @command{guix build}. | |
ef5dd60a | 16264 | |
cf4a9129 LC |
16265 | Both are usually the same and correspond to the lowercase conversion of |
16266 | the project name chosen upstream, with underscores replaced with | |
16267 | hyphens. For instance, GNUnet is available as @code{gnunet}, and | |
16268 | SDL_net as @code{sdl-net}. | |
927097ef | 16269 | |
cf4a9129 | 16270 | We do not add @code{lib} prefixes for library packages, unless these are |
081145cf | 16271 | already part of the official project name. But @pxref{Python |
cf4a9129 LC |
16272 | Modules} and @ref{Perl Modules} for special rules concerning modules for |
16273 | the Python and Perl languages. | |
927097ef | 16274 | |
1b366ee4 | 16275 | Font package names are handled differently, @pxref{Fonts}. |
7fec52b7 | 16276 | |
ef5dd60a | 16277 | |
cf4a9129 LC |
16278 | @node Version Numbers |
16279 | @subsection Version Numbers | |
ef5dd60a | 16280 | |
e32171ee | 16281 | @cindex package version |
cf4a9129 LC |
16282 | We usually package only the latest version of a given free software |
16283 | project. But sometimes, for instance for incompatible library versions, | |
16284 | two (or more) versions of the same package are needed. These require | |
16285 | different Scheme variable names. We use the name as defined | |
16286 | in @ref{Package Naming} | |
16287 | for the most recent version; previous versions use the same name, suffixed | |
16288 | by @code{-} and the smallest prefix of the version number that may | |
16289 | distinguish the two versions. | |
ef5dd60a | 16290 | |
cf4a9129 LC |
16291 | The name inside the package definition is the same for all versions of a |
16292 | package and does not contain any version number. | |
ef5dd60a | 16293 | |
cf4a9129 | 16294 | For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows: |
ef5dd60a | 16295 | |
cf4a9129 LC |
16296 | @example |
16297 | (define-public gtk+ | |
16298 | (package | |
17d8e33f ML |
16299 | (name "gtk+") |
16300 | (version "3.9.12") | |
16301 | ...)) | |
cf4a9129 LC |
16302 | (define-public gtk+-2 |
16303 | (package | |
17d8e33f ML |
16304 | (name "gtk+") |
16305 | (version "2.24.20") | |
16306 | ...)) | |
cf4a9129 LC |
16307 | @end example |
16308 | If we also wanted GTK+ 3.8.2, this would be packaged as | |
16309 | @example | |
16310 | (define-public gtk+-3.8 | |
16311 | (package | |
17d8e33f ML |
16312 | (name "gtk+") |
16313 | (version "3.8.2") | |
16314 | ...)) | |
cf4a9129 | 16315 | @end example |
ef5dd60a | 16316 | |
880d647d LC |
16317 | @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>, |
16318 | @c for a discussion of what follows. | |
16319 | @cindex version number, for VCS snapshots | |
16320 | Occasionally, we package snapshots of upstream's version control system | |
16321 | (VCS) instead of formal releases. This should remain exceptional, | |
16322 | because it is up to upstream developers to clarify what the stable | |
16323 | release is. Yet, it is sometimes necessary. So, what should we put in | |
16324 | the @code{version} field? | |
16325 | ||
16326 | Clearly, we need to make the commit identifier of the VCS snapshot | |
16327 | visible in the version string, but we also need to make sure that the | |
16328 | version string is monotonically increasing so that @command{guix package | |
16329 | --upgrade} can determine which version is newer. Since commit | |
16330 | identifiers, notably with Git, are not monotonically increasing, we add | |
16331 | a revision number that we increase each time we upgrade to a newer | |
16332 | snapshot. The resulting version string looks like this: | |
16333 | ||
16334 | @example | |
16335 | 2.0.11-3.cabba9e | |
16336 | ^ ^ ^ | |
16337 | | | `-- upstream commit ID | |
16338 | | | | |
16339 | | `--- Guix package revision | |
16340 | | | |
16341 | latest upstream version | |
16342 | @end example | |
16343 | ||
16344 | It is a good idea to strip commit identifiers in the @code{version} | |
16345 | field to, say, 7 digits. It avoids an aesthetic annoyance (assuming | |
16346 | aesthetics have a role to play here) as well as problems related to OS | |
16347 | limits such as the maximum shebang length (127 bytes for the Linux | |
16348 | kernel.) It is best to use the full commit identifiers in | |
561360a5 LC |
16349 | @code{origin}s, though, to avoid ambiguities. A typical package |
16350 | definition may look like this: | |
16351 | ||
16352 | @example | |
16353 | (define my-package | |
6e42660b | 16354 | (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7") |
16355 | (revision "1")) ;Guix package revision | |
561360a5 | 16356 | (package |
6e42660b | 16357 | (version (string-append "0.9-" revision "." |
561360a5 LC |
16358 | (string-take commit 7))) |
16359 | (source (origin | |
16360 | (method git-fetch) | |
16361 | (uri (git-reference | |
16362 | (url "git://example.org/my-package.git") | |
16363 | (commit commit))) | |
16364 | (sha256 (base32 "1mbikn@dots{}")) | |
16365 | (file-name (string-append "my-package-" version | |
16366 | "-checkout")))) | |
16367 | ;; @dots{} | |
16368 | ))) | |
16369 | @end example | |
880d647d | 16370 | |
cbd02397 LC |
16371 | @node Synopses and Descriptions |
16372 | @subsection Synopses and Descriptions | |
16373 | ||
e32171ee JD |
16374 | @cindex package description |
16375 | @cindex package synopsis | |
cbd02397 LC |
16376 | As we have seen before, each package in GNU@tie{}Guix includes a |
16377 | synopsis and a description (@pxref{Defining Packages}). Synopses and | |
16378 | descriptions are important: They are what @command{guix package | |
16379 | --search} searches, and a crucial piece of information to help users | |
16380 | determine whether a given package suits their needs. Consequently, | |
16381 | packagers should pay attention to what goes into them. | |
16382 | ||
16383 | Synopses must start with a capital letter and must not end with a | |
16384 | period. They must not start with ``a'' or ``the'', which usually does | |
16385 | not bring anything; for instance, prefer ``File-frobbing tool'' over ``A | |
16386 | tool that frobs files''. The synopsis should say what the package | |
16387 | is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is | |
16388 | used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines | |
16389 | matching a pattern''. | |
16390 | ||
16391 | Keep in mind that the synopsis must be meaningful for a very wide | |
16392 | audience. For example, ``Manipulate alignments in the SAM format'' | |
16393 | might make sense for a seasoned bioinformatics researcher, but might be | |
16394 | fairly unhelpful or even misleading to a non-specialized audience. It | |
16395 | is a good idea to come up with a synopsis that gives an idea of the | |
16396 | application domain of the package. In this example, this might give | |
16397 | something like ``Manipulate nucleotide sequence alignments'', which | |
16398 | hopefully gives the user a better idea of whether this is what they are | |
16399 | looking for. | |
16400 | ||
cbd02397 LC |
16401 | Descriptions should take between five and ten lines. Use full |
16402 | sentences, and avoid using acronyms without first introducing them. | |
762e54b7 LC |
16403 | Please avoid marketing phrases such as ``world-leading'', |
16404 | ``industrial-strength'', and ``next-generation'', and avoid superlatives | |
16405 | like ``the most advanced''---they are not helpful to users looking for a | |
16406 | package and may even sound suspicious. Instead, try to be factual, | |
16407 | mentioning use cases and features. | |
16408 | ||
16409 | @cindex Texinfo markup, in package descriptions | |
cbd02397 LC |
16410 | Descriptions can include Texinfo markup, which is useful to introduce |
16411 | ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or | |
ba7d6c76 ML |
16412 | hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you |
16413 | should be careful when using some characters for example @samp{@@} and | |
16414 | curly braces which are the basic special characters in Texinfo | |
16415 | (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces | |
16416 | such as @command{guix package --show} take care of rendering it | |
16417 | appropriately. | |
cbd02397 LC |
16418 | |
16419 | Synopses and descriptions are translated by volunteers | |
16420 | @uref{http://translationproject.org/domain/guix-packages.html, at the | |
16421 | Translation Project} so that as many users as possible can read them in | |
16422 | their native language. User interfaces search them and display them in | |
16423 | the language specified by the current locale. | |
16424 | ||
16425 | Translation is a lot of work so, as a packager, please pay even more | |
16426 | attention to your synopses and descriptions as every change may entail | |
ba7d6c76 | 16427 | additional work for translators. In order to help them, it is possible |
36743e71 | 16428 | to make recommendations or instructions visible to them by inserting |
ba7d6c76 ML |
16429 | special comments like this (@pxref{xgettext Invocation,,, gettext, GNU |
16430 | Gettext}): | |
16431 | ||
16432 | @example | |
16433 | ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated. | |
16434 | (description "ARandR is designed to provide a simple visual front end | |
16435 | for the X11 resize-and-rotate (RandR) extension. @dots{}") | |
16436 | @end example | |
cbd02397 | 16437 | |
ef5dd60a | 16438 | |
cf4a9129 LC |
16439 | @node Python Modules |
16440 | @subsection Python Modules | |
ef5dd60a | 16441 | |
e32171ee | 16442 | @cindex python |
cf4a9129 LC |
16443 | We currently package Python 2 and Python 3, under the Scheme variable names |
16444 | @code{python-2} and @code{python} as explained in @ref{Version Numbers}. | |
16445 | To avoid confusion and naming clashes with other programming languages, it | |
16446 | seems desirable that the name of a package for a Python module contains | |
16447 | the word @code{python}. | |
ef5dd60a | 16448 | |
cf4a9129 LC |
16449 | Some modules are compatible with only one version of Python, others with both. |
16450 | If the package Foo compiles only with Python 3, we name it | |
16451 | @code{python-foo}; if it compiles only with Python 2, we name it | |
16452 | @code{python2-foo}. If it is compatible with both versions, we create two | |
16453 | packages with the corresponding names. | |
ef5dd60a | 16454 | |
cf4a9129 LC |
16455 | If a project already contains the word @code{python}, we drop this; |
16456 | for instance, the module python-dateutil is packaged under the names | |
99c866a0 HG |
16457 | @code{python-dateutil} and @code{python2-dateutil}. If the project name |
16458 | starts with @code{py} (e.g. @code{pytz}), we keep it and prefix it as | |
16459 | described above. | |
113daf62 | 16460 | |
e940a271 HG |
16461 | @subsubsection Specifying Dependencies |
16462 | @cindex inputs, for Python packages | |
16463 | ||
16464 | Dependency information for Python packages is usually available in the | |
16465 | package source tree, with varying degrees of accuracy: in the | |
16466 | @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}. | |
16467 | ||
16468 | Your mission, when writing a recipe for a Python package, is to map | |
16469 | these dependencies to the appropriate type of ``input'' (@pxref{package | |
16470 | Reference, inputs}). Although the @code{pypi} importer normally does a | |
16471 | good job (@pxref{Invoking guix import}), you may want to check the | |
16472 | following check list to determine which dependency goes where. | |
16473 | ||
16474 | @itemize | |
16475 | ||
aaf75c89 HG |
16476 | @item |
16477 | We currently package Python 2 with @code{setuptools} and @code{pip} | |
16478 | installed like Python 3.4 has per default. Thus you don't need to | |
891a843d HG |
16479 | specify either of these as an input. @command{guix lint} will warn you |
16480 | if you do. | |
aaf75c89 | 16481 | |
e940a271 HG |
16482 | @item |
16483 | Python dependencies required at run time go into | |
16484 | @code{propagated-inputs}. They are typically defined with the | |
16485 | @code{install_requires} keyword in @file{setup.py}, or in the | |
16486 | @file{requirements.txt} file. | |
16487 | ||
16488 | @item | |
16489 | Python packages required only at build time---e.g., those listed with | |
16490 | the @code{setup_requires} keyword in @file{setup.py}---or only for | |
16491 | testing---e.g., those in @code{tests_require}---go into | |
16492 | @code{native-inputs}. The rationale is that (1) they do not need to be | |
16493 | propagated because they are not needed at run time, and (2) in a | |
16494 | cross-compilation context, it's the ``native'' input that we'd want. | |
16495 | ||
aaf75c89 | 16496 | Examples are the @code{pytest}, @code{mock}, and @code{nose} test |
e940a271 HG |
16497 | frameworks. Of course if any of these packages is also required at |
16498 | run-time, it needs to go to @code{propagated-inputs}. | |
16499 | ||
16500 | @item | |
16501 | Anything that does not fall in the previous categories goes to | |
16502 | @code{inputs}, for example programs or C libraries required for building | |
16503 | Python packages containing C extensions. | |
16504 | ||
16505 | @item | |
16506 | If a Python package has optional dependencies (@code{extras_require}), | |
16507 | it is up to you to decide whether to add them or not, based on their | |
16508 | usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix | |
16509 | size}}). | |
16510 | ||
16511 | @end itemize | |
16512 | ||
16513 | ||
cf4a9129 LC |
16514 | @node Perl Modules |
16515 | @subsection Perl Modules | |
523e4896 | 16516 | |
e32171ee | 16517 | @cindex perl |
cf4a9129 LC |
16518 | Perl programs standing for themselves are named as any other package, |
16519 | using the lowercase upstream name. | |
16520 | For Perl packages containing a single class, we use the lowercase class name, | |
16521 | replace all occurrences of @code{::} by dashes and prepend the prefix | |
16522 | @code{perl-}. | |
16523 | So the class @code{XML::Parser} becomes @code{perl-xml-parser}. | |
16524 | Modules containing several classes keep their lowercase upstream name and | |
16525 | are also prepended by @code{perl-}. Such modules tend to have the word | |
16526 | @code{perl} somewhere in their name, which gets dropped in favor of the | |
16527 | prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}. | |
523e4896 | 16528 | |
523e4896 | 16529 | |
e1c963bf HG |
16530 | @node Java Packages |
16531 | @subsection Java Packages | |
16532 | ||
e32171ee | 16533 | @cindex java |
e1c963bf HG |
16534 | Java programs standing for themselves are named as any other package, |
16535 | using the lowercase upstream name. | |
16536 | ||
16537 | To avoid confusion and naming clashes with other programming languages, | |
16538 | it is desirable that the name of a package for a Java package is | |
16539 | prefixed with @code{java-}. If a project already contains the word | |
16540 | @code{java}, we drop this; for instance, the package @code{ngsjava} is | |
16541 | packaged under the name @code{java-ngs}. | |
16542 | ||
16543 | For Java packages containing a single class or a small class hierarchy, | |
16544 | we use the lowercase class name, replace all occurrences of @code{.} by | |
16545 | dashes and prepend the prefix @code{java-}. So the class | |
16546 | @code{apache.commons.cli} becomes package | |
16547 | @code{java-apache-commons-cli}. | |
16548 | ||
16549 | ||
7fec52b7 AE |
16550 | @node Fonts |
16551 | @subsection Fonts | |
16552 | ||
e32171ee | 16553 | @cindex fonts |
7fec52b7 AE |
16554 | For fonts that are in general not installed by a user for typesetting |
16555 | purposes, or that are distributed as part of a larger software package, | |
16556 | we rely on the general packaging rules for software; for instance, this | |
16557 | applies to the fonts delivered as part of the X.Org system or fonts that | |
16558 | are part of TeX Live. | |
16559 | ||
16560 | To make it easier for a user to search for fonts, names for other packages | |
16561 | containing only fonts are constructed as follows, independently of the | |
16562 | upstream package name. | |
16563 | ||
16564 | The name of a package containing only one font family starts with | |
16565 | @code{font-}; it is followed by the foundry name and a dash @code{-} | |
16566 | if the foundry is known, and the font family name, in which spaces are | |
16567 | replaced by dashes (and as usual, all upper case letters are transformed | |
16568 | to lower case). | |
16569 | For example, the Gentium font family by SIL is packaged under the name | |
16570 | @code{font-sil-gentium}. | |
16571 | ||
16572 | For a package containing several font families, the name of the collection | |
16573 | is used in the place of the font family name. | |
16574 | For instance, the Liberation fonts consist of three families, | |
16575 | Liberation Sans, Liberation Serif and Liberation Mono. | |
16576 | These could be packaged separately under the names | |
16577 | @code{font-liberation-sans} and so on; but as they are distributed together | |
16578 | under a common name, we prefer to package them together as | |
16579 | @code{font-liberation}. | |
16580 | ||
16581 | In the case where several formats of the same font family or font collection | |
16582 | are packaged separately, a short form of the format, prepended by a dash, | |
16583 | is added to the package name. We use @code{-ttf} for TrueType fonts, | |
1b366ee4 | 16584 | @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1 |
7fec52b7 AE |
16585 | fonts. |
16586 | ||
16587 | ||
b25937e3 | 16588 | |
cf4a9129 LC |
16589 | @node Bootstrapping |
16590 | @section Bootstrapping | |
b25937e3 | 16591 | |
cf4a9129 | 16592 | @c Adapted from the ELS 2013 paper. |
b25937e3 | 16593 | |
cf4a9129 | 16594 | @cindex bootstrapping |
7889394e | 16595 | |
cf4a9129 LC |
16596 | Bootstrapping in our context refers to how the distribution gets built |
16597 | ``from nothing''. Remember that the build environment of a derivation | |
16598 | contains nothing but its declared inputs (@pxref{Introduction}). So | |
16599 | there's an obvious chicken-and-egg problem: how does the first package | |
16600 | get built? How does the first compiler get compiled? Note that this is | |
16601 | a question of interest only to the curious hacker, not to the regular | |
16602 | user, so you can shamelessly skip this section if you consider yourself | |
16603 | a ``regular user''. | |
72b9d60d | 16604 | |
cf4a9129 LC |
16605 | @cindex bootstrap binaries |
16606 | The GNU system is primarily made of C code, with libc at its core. The | |
16607 | GNU build system itself assumes the availability of a Bourne shell and | |
16608 | command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and | |
16609 | `grep'. Furthermore, build programs---programs that run | |
16610 | @code{./configure}, @code{make}, etc.---are written in Guile Scheme | |
16611 | (@pxref{Derivations}). Consequently, to be able to build anything at | |
16612 | all, from scratch, Guix relies on pre-built binaries of Guile, GCC, | |
16613 | Binutils, libc, and the other packages mentioned above---the | |
16614 | @dfn{bootstrap binaries}. | |
72b9d60d | 16615 | |
cf4a9129 LC |
16616 | These bootstrap binaries are ``taken for granted'', though we can also |
16617 | re-create them if needed (more on that later). | |
72b9d60d | 16618 | |
cf4a9129 | 16619 | @unnumberedsubsec Preparing to Use the Bootstrap Binaries |
c79d54fe | 16620 | |
cf4a9129 LC |
16621 | @c As of Emacs 24.3, Info-mode displays the image, but since it's a |
16622 | @c large image, it's hard to scroll. Oh well. | |
16623 | @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations} | |
523e4896 | 16624 | |
cf4a9129 LC |
16625 | The figure above shows the very beginning of the dependency graph of the |
16626 | distribution, corresponding to the package definitions of the @code{(gnu | |
d33fa0c7 LC |
16627 | packages bootstrap)} module. A similar figure can be generated with |
16628 | @command{guix graph} (@pxref{Invoking guix graph}), along the lines of: | |
16629 | ||
16630 | @example | |
16631 | guix graph -t derivation \ | |
16632 | -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \ | |
16633 | | dot -Tps > t.ps | |
16634 | @end example | |
16635 | ||
16636 | At this level of detail, things are | |
cf4a9129 LC |
16637 | slightly complex. First, Guile itself consists of an ELF executable, |
16638 | along with many source and compiled Scheme files that are dynamically | |
16639 | loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz} | |
16640 | tarball shown in this graph. This tarball is part of Guix's ``source'' | |
16641 | distribution, and gets inserted into the store with @code{add-to-store} | |
16642 | (@pxref{The Store}). | |
2e7b5cea | 16643 | |
cf4a9129 LC |
16644 | But how do we write a derivation that unpacks this tarball and adds it |
16645 | to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv} | |
16646 | derivation---the first one that gets built---uses @code{bash} as its | |
16647 | builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls | |
16648 | @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar}, | |
16649 | @file{xz}, and @file{mkdir} are statically-linked binaries, also part of | |
16650 | the Guix source distribution, whose sole purpose is to allow the Guile | |
16651 | tarball to be unpacked. | |
fb729425 | 16652 | |
cf4a9129 LC |
16653 | Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning |
16654 | Guile that can be used to run subsequent build programs. Its first task | |
16655 | is to download tarballs containing the other pre-built binaries---this | |
16656 | is what the @code{.tar.xz.drv} derivations do. Guix modules such as | |
16657 | @code{ftp-client.scm} are used for this purpose. The | |
16658 | @code{module-import.drv} derivations import those modules in a directory | |
16659 | in the store, using the original layout. The | |
16660 | @code{module-import-compiled.drv} derivations compile those modules, and | |
16661 | write them in an output directory with the right layout. This | |
16662 | corresponds to the @code{#:modules} argument of | |
16663 | @code{build-expression->derivation} (@pxref{Derivations}). | |
fb729425 | 16664 | |
cf4a9129 LC |
16665 | Finally, the various tarballs are unpacked by the |
16666 | derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, | |
16667 | etc., at which point we have a working C tool chain. | |
fb729425 | 16668 | |
fb729425 | 16669 | |
cf4a9129 | 16670 | @unnumberedsubsec Building the Build Tools |
523e4896 | 16671 | |
cf4a9129 LC |
16672 | Bootstrapping is complete when we have a full tool chain that does not |
16673 | depend on the pre-built bootstrap tools discussed above. This | |
16674 | no-dependency requirement is verified by checking whether the files of | |
16675 | the final tool chain contain references to the @file{/gnu/store} | |
16676 | directories of the bootstrap inputs. The process that leads to this | |
16677 | ``final'' tool chain is described by the package definitions found in | |
1f6f57df | 16678 | the @code{(gnu packages commencement)} module. |
df2ce343 | 16679 | |
d33fa0c7 LC |
16680 | The @command{guix graph} command allows us to ``zoom out'' compared to |
16681 | the graph above, by looking at the level of package objects instead of | |
16682 | individual derivations---remember that a package may translate to | |
16683 | several derivations, typically one derivation to download its source, | |
16684 | one to build the Guile modules it needs, and one to actually build the | |
16685 | package from source. The command: | |
16686 | ||
16687 | @example | |
16688 | guix graph -t bag \ | |
16689 | -e '(@@@@ (gnu packages commencement) | |
16690 | glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps | |
16691 | @end example | |
16692 | ||
16693 | @noindent | |
16694 | produces the dependency graph leading to the ``final'' C | |
16695 | library@footnote{You may notice the @code{glibc-intermediate} label, | |
16696 | suggesting that it is not @emph{quite} final, but as a good | |
16697 | approximation, we will consider it final.}, depicted below. | |
16698 | ||
16699 | @image{images/bootstrap-packages,6in,,Dependency graph of the early packages} | |
16700 | ||
cf4a9129 LC |
16701 | @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>. |
16702 | The first tool that gets built with the bootstrap binaries is | |
d33fa0c7 LC |
16703 | GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite |
16704 | for all the following packages. From there Findutils and Diffutils get | |
16705 | built. | |
523e4896 | 16706 | |
cf4a9129 LC |
16707 | Then come the first-stage Binutils and GCC, built as pseudo cross |
16708 | tools---i.e., with @code{--target} equal to @code{--host}. They are | |
16709 | used to build libc. Thanks to this cross-build trick, this libc is | |
16710 | guaranteed not to hold any reference to the initial tool chain. | |
4af2447e | 16711 | |
d33fa0c7 LC |
16712 | From there the final Binutils and GCC (not shown above) are built. |
16713 | GCC uses @code{ld} | |
cf4a9129 LC |
16714 | from the final Binutils, and links programs against the just-built libc. |
16715 | This tool chain is used to build the other packages used by Guix and by | |
16716 | the GNU Build System: Guile, Bash, Coreutils, etc. | |
4af2447e | 16717 | |
cf4a9129 LC |
16718 | And voilà! At this point we have the complete set of build tools that |
16719 | the GNU Build System expects. These are in the @code{%final-inputs} | |
dd164244 MW |
16720 | variable of the @code{(gnu packages commencement)} module, and are |
16721 | implicitly used by any package that uses @code{gnu-build-system} | |
1f6f57df | 16722 | (@pxref{Build Systems, @code{gnu-build-system}}). |
4af2447e | 16723 | |
4af2447e | 16724 | |
cf4a9129 | 16725 | @unnumberedsubsec Building the Bootstrap Binaries |
4af2447e | 16726 | |
e32171ee | 16727 | @cindex bootstrap binaries |
cf4a9129 LC |
16728 | Because the final tool chain does not depend on the bootstrap binaries, |
16729 | those rarely need to be updated. Nevertheless, it is useful to have an | |
16730 | automated way to produce them, should an update occur, and this is what | |
16731 | the @code{(gnu packages make-bootstrap)} module provides. | |
4af2447e | 16732 | |
cf4a9129 LC |
16733 | The following command builds the tarballs containing the bootstrap |
16734 | binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture | |
16735 | of Coreutils and other basic command-line tools): | |
4b2615e1 | 16736 | |
cf4a9129 LC |
16737 | @example |
16738 | guix build bootstrap-tarballs | |
16739 | @end example | |
16740 | ||
16741 | The generated tarballs are those that should be referred to in the | |
16742 | @code{(gnu packages bootstrap)} module mentioned at the beginning of | |
16743 | this section. | |
16744 | ||
16745 | Still here? Then perhaps by now you've started to wonder: when do we | |
16746 | reach a fixed point? That is an interesting question! The answer is | |
16747 | unknown, but if you would like to investigate further (and have | |
16748 | significant computational and storage resources to do so), then let us | |
16749 | know. | |
16750 | ||
16751 | @node Porting | |
16752 | @section Porting to a New Platform | |
16753 | ||
16754 | As discussed above, the GNU distribution is self-contained, and | |
16755 | self-containment is achieved by relying on pre-built ``bootstrap | |
16756 | binaries'' (@pxref{Bootstrapping}). These binaries are specific to an | |
16757 | operating system kernel, CPU architecture, and application binary | |
16758 | interface (ABI). Thus, to port the distribution to a platform that is | |
16759 | not yet supported, one must build those bootstrap binaries, and update | |
16760 | the @code{(gnu packages bootstrap)} module to use them on that platform. | |
16761 | ||
16762 | Fortunately, Guix can @emph{cross compile} those bootstrap binaries. | |
16763 | When everything goes well, and assuming the GNU tool chain supports the | |
16764 | target platform, this can be as simple as running a command like this | |
16765 | one: | |
16766 | ||
16767 | @example | |
16768 | guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs | |
16769 | @end example | |
16770 | ||
1c0c417d LC |
16771 | For this to work, the @code{glibc-dynamic-linker} procedure in |
16772 | @code{(gnu packages bootstrap)} must be augmented to return the right | |
16773 | file name for libc's dynamic linker on that platform; likewise, | |
16774 | @code{system->linux-architecture} in @code{(gnu packages linux)} must be | |
16775 | taught about the new platform. | |
16776 | ||
cf4a9129 | 16777 | Once these are built, the @code{(gnu packages bootstrap)} module needs |
1c0c417d LC |
16778 | to be updated to refer to these binaries on the target platform. That |
16779 | is, the hashes and URLs of the bootstrap tarballs for the new platform | |
16780 | must be added alongside those of the currently supported platforms. The | |
16781 | bootstrap Guile tarball is treated specially: it is expected to be | |
03d0e2d2 | 16782 | available locally, and @file{gnu/local.mk} has rules do download it for |
1c0c417d LC |
16783 | the supported architectures; a rule for the new platform must be added |
16784 | as well. | |
cf4a9129 LC |
16785 | |
16786 | In practice, there may be some complications. First, it may be that the | |
16787 | extended GNU triplet that specifies an ABI (like the @code{eabi} suffix | |
16788 | above) is not recognized by all the GNU tools. Typically, glibc | |
16789 | recognizes some of these, whereas GCC uses an extra @code{--with-abi} | |
16790 | configure flag (see @code{gcc.scm} for examples of how to handle this). | |
16791 | Second, some of the required packages could fail to build for that | |
16792 | platform. Lastly, the generated binaries could be broken for some | |
16793 | reason. | |
4af2447e | 16794 | |
9bf3c1a7 | 16795 | @c ********************************************************************* |
8c01b9d0 | 16796 | @include contributing.texi |
c78bd12b | 16797 | |
568717fd LC |
16798 | @c ********************************************************************* |
16799 | @node Acknowledgments | |
16800 | @chapter Acknowledgments | |
16801 | ||
136787cb LC |
16802 | Guix is based on the @uref{http://nixos.org/nix/, Nix package manager}, |
16803 | which was designed and | |
4c7ac9aa LC |
16804 | implemented by Eelco Dolstra, with contributions from other people (see |
16805 | the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package | |
568717fd LC |
16806 | management, and promoted unprecedented features, such as transactional |
16807 | package upgrades and rollbacks, per-user profiles, and referentially | |
16808 | transparent build processes. Without this work, Guix would not exist. | |
16809 | ||
16810 | The Nix-based software distributions, Nixpkgs and NixOS, have also been | |
16811 | an inspiration for Guix. | |
16812 | ||
4c7ac9aa LC |
16813 | GNU@tie{}Guix itself is a collective work with contributions from a |
16814 | number of people. See the @file{AUTHORS} file in Guix for more | |
16815 | information on these fine people. The @file{THANKS} file lists people | |
16816 | who have helped by reporting bugs, taking care of the infrastructure, | |
16817 | providing artwork and themes, making suggestions, and more---thank you! | |
16818 | ||
16819 | ||
568717fd LC |
16820 | @c ********************************************************************* |
16821 | @node GNU Free Documentation License | |
16822 | @appendix GNU Free Documentation License | |
e32171ee | 16823 | @cindex license, GNU Free Documentation License |
568717fd LC |
16824 | @include fdl-1.3.texi |
16825 | ||
16826 | @c ********************************************************************* | |
16827 | @node Concept Index | |
16828 | @unnumbered Concept Index | |
16829 | @printindex cp | |
16830 | ||
a85b83d2 LC |
16831 | @node Programming Index |
16832 | @unnumbered Programming Index | |
16833 | @syncodeindex tp fn | |
16834 | @syncodeindex vr fn | |
568717fd LC |
16835 | @printindex fn |
16836 | ||
16837 | @bye | |
16838 | ||
16839 | @c Local Variables: | |
16840 | @c ispell-local-dictionary: "american"; | |
16841 | @c End: |