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@* |
6e42660b | 27 | Copyright @copyright{} 2016 Efraim Flashner@* |
d6a07ee6 | 28 | Copyright @copyright{} 2016 John Darrington@* |
92c03a87 | 29 | Copyright @copyright{} 2016 ng0@* |
8c00b838 | 30 | Copyright @copyright{} 2016 Jan Nieuwenhuizen@* |
9747d189 | 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 CZ |
35 | Copyright @copyright{} 2017 Federico Beffa@* |
36 | Copyright @copyright{} 2017 Carlo Zancanaro | |
7df7a74e NK |
37 | |
38 | Permission is granted to copy, distribute and/or modify this document | |
39 | under the terms of the GNU Free Documentation License, Version 1.3 or | |
40 | any later version published by the Free Software Foundation; with no | |
41 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A | |
42 | copy of the license is included in the section entitled ``GNU Free | |
43 | Documentation License''. | |
44 | @end copying | |
568717fd | 45 | |
abd67856 | 46 | @dircategory System administration |
568717fd | 47 | @direntry |
abd67856 LC |
48 | * Guix: (guix). Manage installed software and system configuration. |
49 | * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages. | |
abd67856 LC |
50 | * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space. |
51 | * guix pull: (guix)Invoking guix pull. Update the list of available packages. | |
52 | * guix system: (guix)Invoking guix system. Manage the operating system configuration. | |
568717fd | 53 | @end direntry |
568717fd | 54 | |
372c4bbc DT |
55 | @dircategory Software development |
56 | @direntry | |
abd67856 | 57 | * guix environment: (guix)Invoking guix environment. Building development environments with Guix. |
ad172c4a LC |
58 | * guix build: (guix)Invoking guix build. Building packages. |
59 | * guix pack: (guix)Invoking guix pack. Creating binary bundles. | |
372c4bbc DT |
60 | @end direntry |
61 | ||
568717fd | 62 | @titlepage |
7730d112 LC |
63 | @title GNU Guix Reference Manual |
64 | @subtitle Using the GNU Guix Functional Package Manager | |
2cbed07e | 65 | @author The GNU Guix Developers |
568717fd LC |
66 | |
67 | @page | |
68 | @vskip 0pt plus 1filll | |
69 | Edition @value{EDITION} @* | |
70 | @value{UPDATED} @* | |
71 | ||
7df7a74e | 72 | @insertcopying |
568717fd LC |
73 | @end titlepage |
74 | ||
568717fd LC |
75 | @contents |
76 | ||
77 | @c ********************************************************************* | |
78 | @node Top | |
f8348b91 | 79 | @top GNU Guix |
568717fd | 80 | |
f8348b91 LC |
81 | This document describes GNU Guix version @value{VERSION}, a functional |
82 | package management tool written for the GNU system. | |
568717fd LC |
83 | |
84 | @menu | |
85 | * Introduction:: What is Guix about? | |
bd5e766b | 86 | * Installation:: Installing Guix. |
eeaf4427 | 87 | * Package Management:: Package installation, upgrade, etc. |
568717fd LC |
88 | * Programming Interface:: Using Guix in Scheme. |
89 | * Utilities:: Package management commands. | |
a1ba8475 | 90 | * GNU Distribution:: Software for your friendly GNU system. |
9bf3c1a7 | 91 | * Contributing:: Your help needed! |
568717fd LC |
92 | |
93 | * Acknowledgments:: Thanks! | |
94 | * GNU Free Documentation License:: The license of this manual. | |
95 | * Concept Index:: Concepts. | |
a85b83d2 | 96 | * Programming Index:: Data types, functions, and variables. |
aaa3eaa9 LC |
97 | |
98 | @detailmenu | |
99 | --- The Detailed Node Listing --- | |
100 | ||
101 | Installation | |
102 | ||
1b2b8177 | 103 | * Binary Installation:: Getting Guix running in no time! |
aaa3eaa9 | 104 | * Requirements:: Software needed to build and run Guix. |
ec0339cd | 105 | * Running the Test Suite:: Testing Guix. |
aaa3eaa9 LC |
106 | * Setting Up the Daemon:: Preparing the build daemon's environment. |
107 | * Invoking guix-daemon:: Running the build daemon. | |
0e2d0213 | 108 | * Application Setup:: Application-specific setup. |
aaa3eaa9 LC |
109 | |
110 | Setting Up the Daemon | |
111 | ||
112 | * Build Environment Setup:: Preparing the isolated build environment. | |
113 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
114 | ||
115 | Package Management | |
116 | ||
117 | * Features:: How Guix will make your life brighter. | |
118 | * Invoking guix package:: Package installation, removal, etc. | |
aaa3eaa9 LC |
119 | * Substitutes:: Downloading pre-built binaries. |
120 | * Packages with Multiple Outputs:: Single source package, multiple outputs. | |
121 | * Invoking guix gc:: Running the garbage collector. | |
122 | * Invoking guix pull:: Fetching the latest Guix and distribution. | |
239c2266 | 123 | * Invoking guix pack:: Creating software bundles. |
aaa3eaa9 LC |
124 | * Invoking guix archive:: Exporting and importing store files. |
125 | ||
126 | Programming Interface | |
127 | ||
128 | * Defining Packages:: Defining new packages. | |
129 | * Build Systems:: Specifying how packages are built. | |
130 | * The Store:: Manipulating the package store. | |
131 | * Derivations:: Low-level interface to package derivations. | |
132 | * The Store Monad:: Purely functional interface to the store. | |
133 | * G-Expressions:: Manipulating build expressions. | |
134 | ||
92492b23 LC |
135 | Defining Packages |
136 | ||
137 | * package Reference:: The package data type. | |
138 | * origin Reference:: The origin data type. | |
139 | ||
aaa3eaa9 LC |
140 | Utilities |
141 | ||
142 | * Invoking guix build:: Building packages from the command line. | |
fcc58db6 | 143 | * Invoking guix edit:: Editing package definitions. |
aaa3eaa9 LC |
144 | * Invoking guix download:: Downloading a file and printing its hash. |
145 | * Invoking guix hash:: Computing the cryptographic hash of a file. | |
146 | * Invoking guix import:: Importing package definitions. | |
147 | * Invoking guix refresh:: Updating package definitions. | |
148 | * Invoking guix lint:: Finding errors in package definitions. | |
fcc58db6 | 149 | * Invoking guix size:: Profiling disk usage. |
88856916 | 150 | * Invoking guix graph:: Visualizing the graph of packages. |
aaa3eaa9 | 151 | * Invoking guix environment:: Setting up development environments. |
aff8ce7c | 152 | * Invoking guix publish:: Sharing substitutes. |
d23c20f1 | 153 | * Invoking guix challenge:: Challenging substitute servers. |
f11c444d | 154 | * Invoking guix copy:: Copying to and from a remote store. |
32efa254 | 155 | * Invoking guix container:: Process isolation. |
aaa3eaa9 | 156 | |
e3009f60 LC |
157 | Invoking @command{guix build} |
158 | ||
159 | * Common Build Options:: Build options for most commands. | |
f11c444d | 160 | * Package Transformation Options:: Creating variants of packages. |
e3009f60 LC |
161 | * Additional Build Options:: Options specific to 'guix build'. |
162 | ||
aaa3eaa9 LC |
163 | GNU Distribution |
164 | ||
165 | * System Installation:: Installing the whole operating system. | |
35ed9306 | 166 | * System Configuration:: Configuring the operating system. |
aaa3eaa9 LC |
167 | * Installing Debugging Files:: Feeding the debugger. |
168 | * Security Updates:: Deploying security fixes quickly. | |
169 | * Package Modules:: Packages from the programmer's viewpoint. | |
170 | * Packaging Guidelines:: Growing the distribution. | |
171 | * Bootstrapping:: GNU/Linux built from scratch. | |
172 | * Porting:: Targeting another platform or kernel. | |
173 | ||
e3009f60 LC |
174 | System Installation |
175 | ||
176 | * Limitations:: What you can expect. | |
177 | * Hardware Considerations:: Supported hardware. | |
178 | * USB Stick Installation:: Preparing the installation medium. | |
179 | * Preparing for Installation:: Networking, partitioning, etc. | |
180 | * Proceeding with the Installation:: The real thing. | |
c8b54374 | 181 | * Installing GuixSD in a VM:: GuixSD playground. |
e3009f60 LC |
182 | * Building the Installation Image:: How this comes to be. |
183 | ||
aaa3eaa9 LC |
184 | System Configuration |
185 | ||
186 | * Using the Configuration System:: Customizing your GNU system. | |
187 | * operating-system Reference:: Detail of operating-system declarations. | |
188 | * File Systems:: Configuring file system mounts. | |
189 | * Mapped Devices:: Block device extra processing. | |
190 | * User Accounts:: Specifying user accounts. | |
598e19dc | 191 | * Locales:: Language and cultural convention settings. |
aaa3eaa9 LC |
192 | * Services:: Specifying system services. |
193 | * Setuid Programs:: Programs running with root privileges. | |
1b2b8177 | 194 | * X.509 Certificates:: Authenticating HTTPS servers. |
996ed739 | 195 | * Name Service Switch:: Configuring libc's name service switch. |
aaa3eaa9 LC |
196 | * Initial RAM Disk:: Linux-Libre bootstrapping. |
197 | * GRUB Configuration:: Configuring the boot loader. | |
198 | * Invoking guix system:: Instantiating a system configuration. | |
97d76250 | 199 | * Running GuixSD in a VM:: How to run GuixSD in a virtual machine. |
aaa3eaa9 LC |
200 | * Defining Services:: Adding new service definitions. |
201 | ||
202 | Services | |
203 | ||
204 | * Base Services:: Essential system services. | |
c311089b | 205 | * Scheduled Job Execution:: The mcron service. |
92c03a87 | 206 | * Log Rotation:: The rottlog service. |
aaa3eaa9 LC |
207 | * Networking Services:: Network setup, SSH daemon, etc. |
208 | * X Window:: Graphical display. | |
f11c444d | 209 | * Printing Services:: Local and remote printer support. |
1b2b8177 LC |
210 | * Desktop Services:: D-Bus and desktop services. |
211 | * Database Services:: SQL databases. | |
d8c18af8 | 212 | * Mail Services:: IMAP, POP3, SMTP, and all that. |
78cef99b | 213 | * Messaging Services:: Messaging services. |
859e367d | 214 | * Kerberos Services:: Kerberos services. |
cbd02397 | 215 | * Web Services:: Web servers. |
2be1b471 | 216 | * VPN Services:: VPN daemons. |
eb419bc9 | 217 | * Network File System:: NFS related services. |
f11c444d | 218 | * Continuous Integration:: The Cuirass service. |
dbc6d370 | 219 | * Miscellaneous Services:: Other services. |
aaa3eaa9 | 220 | |
0adfe95a LC |
221 | Defining Services |
222 | ||
223 | * Service Composition:: The model for composing services. | |
224 | * Service Types and Services:: Types and services. | |
225 | * Service Reference:: API reference. | |
dd17bc38 | 226 | * Shepherd Services:: A particular type of service. |
0adfe95a | 227 | |
aaa3eaa9 LC |
228 | Packaging Guidelines |
229 | ||
ec0339cd LC |
230 | * Software Freedom:: What may go into the distribution. |
231 | * Package Naming:: What's in a name? | |
232 | * Version Numbers:: When the name is not enough. | |
cbd02397 | 233 | * Synopses and Descriptions:: Helping users find the right package. |
ec0339cd LC |
234 | * Python Modules:: Taming the snake. |
235 | * Perl Modules:: Little pearls. | |
e1c963bf | 236 | * Java Packages:: Coffee break. |
ec0339cd | 237 | * Fonts:: Fond of fonts. |
aaa3eaa9 | 238 | |
8c01b9d0 ML |
239 | Contributing |
240 | ||
241 | * Building from Git:: The latest and greatest. | |
242 | * Running Guix Before It Is Installed:: Hacker tricks. | |
243 | * The Perfect Setup:: The right tools. | |
244 | * Coding Style:: Hygiene of the contributor. | |
245 | * Submitting Patches:: Share your work. | |
246 | ||
247 | Coding Style | |
248 | ||
249 | * Programming Paradigm:: How to compose your elements. | |
250 | * Modules:: Where to store your code? | |
251 | * Data Types and Pattern Matching:: Implementing data structures. | |
252 | * Formatting Code:: Writing conventions. | |
253 | ||
aaa3eaa9 | 254 | @end detailmenu |
568717fd LC |
255 | @end menu |
256 | ||
257 | @c ********************************************************************* | |
258 | @node Introduction | |
259 | @chapter Introduction | |
260 | ||
6f773606 | 261 | @cindex purpose |
c80e7e55 | 262 | GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks'' |
6f773606 LC |
263 | using the international phonetic alphabet (IPA).} is a package |
264 | management tool for the GNU system. Guix makes it easy for unprivileged | |
265 | users to install, upgrade, or remove packages, to roll back to a | |
266 | previous package set, to build packages from source, and generally | |
267 | assists with the creation and maintenance of software environments. | |
268 | ||
269 | @cindex user interfaces | |
270 | Guix provides a command-line package management interface | |
271 | (@pxref{Invoking guix package}), a set of command-line utilities | |
deb6276d | 272 | (@pxref{Utilities}), as well as Scheme programming interfaces |
6f773606 LC |
273 | (@pxref{Programming Interface}). |
274 | @cindex build daemon | |
275 | Its @dfn{build daemon} is responsible for building packages on behalf of | |
276 | users (@pxref{Setting Up the Daemon}) and for downloading pre-built | |
277 | binaries from authorized sources (@pxref{Substitutes}). | |
278 | ||
279 | @cindex extensibility of the distribution | |
e32171ee | 280 | @cindex customization, of packages |
6f773606 LC |
281 | Guix includes package definitions for many GNU and non-GNU packages, all |
282 | of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the | |
283 | user's computing freedom}. It is @emph{extensible}: users can write | |
284 | their own package definitions (@pxref{Defining Packages}) and make them | |
285 | available as independent package modules (@pxref{Package Modules}). It | |
286 | is also @emph{customizable}: users can @emph{derive} specialized package | |
287 | definitions from existing ones, including from the command line | |
288 | (@pxref{Package Transformation Options}). | |
289 | ||
290 | @cindex Guix System Distribution | |
291 | @cindex GuixSD | |
292 | You can install GNU@tie{}Guix on top of an existing GNU/Linux system | |
293 | where it complements the available tools without interference | |
294 | (@pxref{Installation}), or you can use it as part of the standalone | |
295 | @dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}). | |
296 | With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating | |
297 | system configuration and Guix takes care of instantiating the | |
298 | configuration in a transactional, reproducible, and stateless fashion | |
299 | (@pxref{System Configuration}). | |
568717fd LC |
300 | |
301 | @cindex functional package management | |
6f773606 | 302 | Under the hood, Guix implements the @dfn{functional package management} |
136787cb LC |
303 | discipline pioneered by Nix (@pxref{Acknowledgments}). |
304 | In Guix, the package build and installation process is seen | |
6f773606 | 305 | as a @emph{function}, in the mathematical sense. That function takes inputs, |
4bfc4ea3 NK |
306 | such as build scripts, a compiler, and libraries, and |
307 | returns an installed package. As a pure function, its result depends | |
568717fd LC |
308 | solely on its inputs---for instance, it cannot refer to software or |
309 | scripts that were not explicitly passed as inputs. A build function | |
4bfc4ea3 | 310 | always produces the same result when passed a given set of inputs. It |
f97c9175 | 311 | cannot alter the environment of the running system in |
568717fd LC |
312 | any way; for instance, it cannot create, modify, or delete files outside |
313 | of its build and installation directories. This is achieved by running | |
e900c503 | 314 | build processes in isolated environments (or @dfn{containers}), where only their |
4bfc4ea3 | 315 | explicit inputs are visible. |
568717fd | 316 | |
e531ac2a | 317 | @cindex store |
568717fd | 318 | The result of package build functions is @dfn{cached} in the file |
e531ac2a | 319 | system, in a special directory called @dfn{the store} (@pxref{The |
f97c9175 | 320 | Store}). Each package is installed in a directory of its own in the |
834129e0 | 321 | store---by default under @file{/gnu/store}. The directory name contains |
568717fd LC |
322 | a hash of all the inputs used to build that package; thus, changing an |
323 | input yields a different directory name. | |
324 | ||
f97c9175 AE |
325 | This approach is the foundation for the salient features of Guix: support |
326 | for transactional package upgrade and rollback, per-user installation, and | |
eeaf4427 | 327 | garbage collection of packages (@pxref{Features}). |
568717fd | 328 | |
a1ba8475 | 329 | |
bd5e766b LC |
330 | @c ********************************************************************* |
331 | @node Installation | |
332 | @chapter Installation | |
333 | ||
e32171ee | 334 | @cindex installing Guix |
48febeb8 LC |
335 | GNU Guix is available for download from its website at |
336 | @url{http://www.gnu.org/software/guix/}. This section describes the | |
337 | software requirements of Guix, as well as how to install it and get | |
338 | ready to use it. | |
bd5e766b | 339 | |
5af6de3e LC |
340 | Note that this section is concerned with the installation of the package |
341 | manager, which can be done on top of a running GNU/Linux system. If, | |
342 | instead, you want to install the complete GNU operating system, | |
6621cdb6 | 343 | @pxref{System Installation}. |
5af6de3e | 344 | |
d23ef788 LC |
345 | @cindex foreign distro |
346 | When installed on a running GNU/Linux system---thereafter called a | |
347 | @dfn{foreign distro}---GNU@tie{}Guix complements the available tools | |
348 | without interference. Its data lives exclusively in two directories, | |
349 | usually @file{/gnu/store} and @file{/var/guix}; other files on your | |
350 | system, such as @file{/etc}, are left untouched. | |
351 | ||
7fcf2a0b LC |
352 | Once installed, Guix can be updated by running @command{guix pull} |
353 | (@pxref{Invoking guix pull}). | |
354 | ||
bd5e766b | 355 | @menu |
09722b11 | 356 | * Binary Installation:: Getting Guix running in no time! |
bd5e766b | 357 | * Requirements:: Software needed to build and run Guix. |
ec0339cd | 358 | * Running the Test Suite:: Testing Guix. |
bd5e766b LC |
359 | * Setting Up the Daemon:: Preparing the build daemon's environment. |
360 | * Invoking guix-daemon:: Running the build daemon. | |
0e2d0213 | 361 | * Application Setup:: Application-specific setup. |
bd5e766b LC |
362 | @end menu |
363 | ||
09722b11 LC |
364 | @node Binary Installation |
365 | @section Binary Installation | |
366 | ||
e32171ee | 367 | @cindex installing Guix from binaries |
09722b11 LC |
368 | This section describes how to install Guix on an arbitrary system from a |
369 | self-contained tarball providing binaries for Guix and for all its | |
370 | dependencies. This is often quicker than installing from source, which | |
371 | is described in the next sections. The only requirement is to have | |
372 | GNU@tie{}tar and Xz. | |
373 | ||
374 | Installing goes along these lines: | |
375 | ||
376 | @enumerate | |
377 | @item | |
e32171ee | 378 | @cindex downloading Guix binary |
09722b11 | 379 | Download the binary tarball from |
daa8922a LC |
380 | @indicateurl{ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz}, |
381 | where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine | |
382 | already running the kernel Linux, and so on. | |
383 | ||
debc6360 | 384 | @c The following is somewhat duplicated in ``System Installation''. |
daa8922a LC |
385 | Make sure to download the associated @file{.sig} file and to verify the |
386 | authenticity of the tarball against it, along these lines: | |
387 | ||
388 | @example | |
389 | $ wget ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig | |
390 | $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig | |
391 | @end example | |
392 | ||
f97c9175 | 393 | If that command fails because you do not have the required public key, |
daa8922a LC |
394 | then run this command to import it: |
395 | ||
396 | @example | |
debc6360 | 397 | $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID} |
daa8922a LC |
398 | @end example |
399 | ||
400 | @noindent | |
401 | and rerun the @code{gpg --verify} command. | |
debc6360 | 402 | @c end authentication part |
09722b11 LC |
403 | |
404 | @item | |
405 | As @code{root}, run: | |
406 | ||
407 | @example | |
5dc42964 | 408 | # cd /tmp |
254b1c2e LC |
409 | # tar --warning=no-timestamp -xf \ |
410 | guix-binary-@value{VERSION}.@var{system}.tar.xz | |
5dc42964 | 411 | # mv var/guix /var/ && mv gnu / |
09722b11 LC |
412 | @end example |
413 | ||
7acd3439 LC |
414 | This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}. |
415 | The latter contains a ready-to-use profile for @code{root} (see next | |
416 | step.) | |
09722b11 | 417 | |
5dc3ce5f LC |
418 | Do @emph{not} unpack the tarball on a working Guix system since that |
419 | would overwrite its own essential files. | |
420 | ||
254b1c2e | 421 | The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does |
e9ba6357 LC |
422 | not emit warnings about ``implausibly old time stamps'' (such |
423 | warnings were triggered by GNU@tie{}tar 1.26 and older; recent | |
424 | versions are fine.) | |
425 | They stem from the fact that all the | |
254b1c2e LC |
426 | files in the archive have their modification time set to zero (which |
427 | means January 1st, 1970.) This is done on purpose to make sure the | |
428 | archive content is independent of its creation time, thus making it | |
429 | reproducible. | |
430 | ||
7acd3439 LC |
431 | @item |
432 | Make @code{root}'s profile available under @file{~/.guix-profile}: | |
433 | ||
434 | @example | |
435 | # ln -sf /var/guix/profiles/per-user/root/guix-profile \ | |
436 | ~root/.guix-profile | |
437 | @end example | |
438 | ||
43c33047 LC |
439 | @item |
440 | Create the group and user accounts for build users as explained below | |
441 | (@pxref{Build Environment Setup}). | |
442 | ||
09722b11 | 443 | @item |
bf98aea9 | 444 | Run the daemon, and set it to automatically start on boot. |
c8e26887 | 445 | |
bf98aea9 LC |
446 | If your host distro uses the systemd init system, this can be achieved |
447 | with these commands: | |
c8e26887 | 448 | |
b812da70 LF |
449 | @c Versions of systemd that supported symlinked service files are not |
450 | @c yet widely deployed, so we should suggest that users copy the service | |
451 | @c files into place. | |
452 | @c | |
453 | @c See this thread for more information: | |
454 | @c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html | |
455 | ||
c8e26887 | 456 | @example |
b812da70 | 457 | # cp ~root/.guix-profile/lib/systemd/system/guix-daemon.service \ |
c8e26887 GC |
458 | /etc/systemd/system/ |
459 | # systemctl start guix-daemon && systemctl enable guix-daemon | |
460 | @end example | |
461 | ||
462 | If your host distro uses the Upstart init system: | |
09722b11 LC |
463 | |
464 | @example | |
4a780bdf | 465 | # initctl reload-configuration |
b812da70 | 466 | # cp ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/ |
bf98aea9 | 467 | # start guix-daemon |
09722b11 LC |
468 | @end example |
469 | ||
c8e26887 GC |
470 | Otherwise, you can still start the daemon manually with: |
471 | ||
472 | @example | |
473 | # ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild | |
474 | @end example | |
d2825c96 | 475 | |
09722b11 LC |
476 | @item |
477 | Make the @command{guix} command available to other users on the machine, | |
478 | for instance with: | |
479 | ||
480 | @example | |
481 | # mkdir -p /usr/local/bin | |
482 | # cd /usr/local/bin | |
d72d05f9 | 483 | # ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix |
09722b11 | 484 | @end example |
39f8ed14 | 485 | |
aca738f3 LC |
486 | It is also a good idea to make the Info version of this manual available |
487 | there: | |
488 | ||
489 | @example | |
490 | # mkdir -p /usr/local/share/info | |
491 | # cd /usr/local/share/info | |
492 | # for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ; | |
493 | do ln -s $i ; done | |
494 | @end example | |
495 | ||
496 | That way, assuming @file{/usr/local/share/info} is in the search path, | |
497 | running @command{info guix} will open this manual (@pxref{Other Info | |
498 | Directories,,, texinfo, GNU Texinfo}, for more details on changing the | |
499 | Info search path.) | |
500 | ||
39f8ed14 | 501 | @item |
e32171ee | 502 | @cindex substitutes, authorization thereof |
df061d07 LC |
503 | To use substitutes from @code{hydra.gnu.org} or one of its mirrors |
504 | (@pxref{Substitutes}), authorize them: | |
39f8ed14 LC |
505 | |
506 | @example | |
7acd3439 | 507 | # guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub |
39f8ed14 | 508 | @end example |
09722b11 LC |
509 | @end enumerate |
510 | ||
bf98aea9 | 511 | This completes root-level install of Guix. Each user will need to |
7414de0a | 512 | perform additional steps to make their Guix environment ready for use, |
c8e26887 | 513 | @pxref{Application Setup}. |
09722b11 | 514 | |
c8e26887 GC |
515 | You can confirm that Guix is working by installing a sample package into |
516 | the root profile: | |
09722b11 LC |
517 | |
518 | @example | |
c8e26887 | 519 | # guix package -i hello |
09722b11 LC |
520 | @end example |
521 | ||
c8e26887 GC |
522 | The @code{guix} package must remain available in @code{root}'s profile, |
523 | or it would become subject to garbage collection---in which case you | |
524 | would find yourself badly handicapped by the lack of the @command{guix} | |
bf98aea9 LC |
525 | command. In other words, do not remove @code{guix} by running |
526 | @code{guix package -r guix}. | |
527 | ||
528 | The binary installation tarball can be (re)produced and verified simply | |
529 | by running the following command in the Guix source tree: | |
530 | ||
531 | @example | |
532 | make guix-binary.@var{system}.tar.xz | |
533 | @end example | |
c8e26887 | 534 | |
239c2266 LC |
535 | @noindent |
536 | ... which, in turn, runs: | |
537 | ||
538 | @example | |
6b63c43e | 539 | guix pack -s @var{system} --localstatedir guix |
239c2266 LC |
540 | @end example |
541 | ||
542 | @xref{Invoking guix pack}, for more info on this handy tool. | |
09722b11 | 543 | |
bd5e766b LC |
544 | @node Requirements |
545 | @section Requirements | |
546 | ||
09722b11 LC |
547 | This section lists requirements when building Guix from source. The |
548 | build procedure for Guix is the same as for other GNU software, and is | |
549 | not covered here. Please see the files @file{README} and @file{INSTALL} | |
550 | in the Guix source tree for additional details. | |
551 | ||
bd5e766b LC |
552 | GNU Guix depends on the following packages: |
553 | ||
554 | @itemize | |
36626c55 | 555 | @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.9 or |
608e42e7 | 556 | later, including 2.2.x; |
288dca55 | 557 | @item @url{http://gnupg.org/, GNU libgcrypt}; |
1dbe3a8d LC |
558 | @item |
559 | @uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings | |
560 | (@pxref{Guile Preparations, how to install the GnuTLS bindings for | |
561 | Guile,, gnutls-guile, GnuTLS-Guile}); | |
f0b98b84 | 562 | @item @url{http://www.gnu.org/software/make/, GNU Make}. |
8a96bd4b ID |
563 | @end itemize |
564 | ||
565 | The following dependencies are optional: | |
566 | ||
567 | @itemize | |
288dca55 | 568 | @item |
8a96bd4b | 569 | Installing |
288dca55 | 570 | @url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will |
2f7d2d91 LC |
571 | allow you to use the @command{guix import pypi} command (@pxref{Invoking |
572 | guix import}). It is of | |
288dca55 | 573 | interest primarily for developers and not for casual users. |
4591c02e | 574 | |
21531add LC |
575 | @item |
576 | @c Note: We need at least 0.10.2 for 'channel-send-eof'. | |
f11c444d LC |
577 | Support for build offloading (@pxref{Daemon Offload Setup}) and |
578 | @command{guix copy} (@pxref{Invoking guix copy}) depends on | |
21531add LC |
579 | @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH}, |
580 | version 0.10.2 or later. | |
581 | ||
4591c02e LC |
582 | @item |
583 | When @url{http://zlib.net, zlib} is available, @command{guix publish} | |
584 | can compress build byproducts (@pxref{Invoking guix publish}). | |
bd5e766b LC |
585 | @end itemize |
586 | ||
587 | Unless @code{--disable-daemon} was passed to @command{configure}, the | |
588 | following packages are also needed: | |
589 | ||
590 | @itemize | |
368d08f7 LC |
591 | @item @url{http://sqlite.org, SQLite 3}; |
592 | @item @url{http://www.bzip.org, libbz2}; | |
593 | @item @url{http://gcc.gnu.org, GCC's g++}, with support for the | |
594 | C++11 standard. | |
bd5e766b LC |
595 | @end itemize |
596 | ||
e32171ee | 597 | @cindex state directory |
ef5f5c86 LC |
598 | When configuring Guix on a system that already has a Guix installation, |
599 | be sure to specify the same state directory as the existing installation | |
600 | using the @code{--localstatedir} option of the @command{configure} | |
601 | script (@pxref{Directory Variables, @code{localstatedir},, standards, | |
602 | GNU Coding Standards}). The @command{configure} script protects against | |
603 | unintended misconfiguration of @var{localstatedir} so you do not | |
604 | inadvertently corrupt your store (@pxref{The Store}). | |
605 | ||
e32171ee | 606 | @cindex Nix, compatibility |
4bfc4ea3 NK |
607 | When a working installation of @url{http://nixos.org/nix/, the Nix package |
608 | manager} is available, you | |
bd5e766b | 609 | can instead configure Guix with @code{--disable-daemon}. In that case, |
4bfc4ea3 | 610 | Nix replaces the three dependencies above. |
bd5e766b | 611 | |
b22a12fd LC |
612 | Guix is compatible with Nix, so it is possible to share the same store |
613 | between both. To do so, you must pass @command{configure} not only the | |
614 | same @code{--with-store-dir} value, but also the same | |
4bfc4ea3 NK |
615 | @code{--localstatedir} value. The latter is essential because it |
616 | specifies where the database that stores metadata about the store is | |
834129e0 | 617 | located, among other things. The default values for Nix are |
b22a12fd | 618 | @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}. |
4bfc4ea3 NK |
619 | Note that @code{--disable-daemon} is not required if |
620 | your goal is to share the store with Nix. | |
b22a12fd | 621 | |
ec0339cd LC |
622 | @node Running the Test Suite |
623 | @section Running the Test Suite | |
624 | ||
e32171ee | 625 | @cindex test suite |
ec0339cd LC |
626 | After a successful @command{configure} and @code{make} run, it is a good |
627 | idea to run the test suite. It can help catch issues with the setup or | |
628 | environment, or bugs in Guix itself---and really, reporting test | |
629 | failures is a good way to help improve the software. To run the test | |
630 | suite, type: | |
631 | ||
632 | @example | |
633 | make check | |
634 | @end example | |
635 | ||
636 | Test cases can run in parallel: you can use the @code{-j} option of | |
637 | GNU@tie{}make to speed things up. The first run may take a few minutes | |
638 | on a recent machine; subsequent runs will be faster because the store | |
639 | that is created for test purposes will already have various things in | |
640 | cache. | |
641 | ||
a887fd8d LC |
642 | It is also possible to run a subset of the tests by defining the |
643 | @code{TESTS} makefile variable as in this example: | |
644 | ||
645 | @example | |
646 | make check TESTS="tests/store.scm tests/cpio.scm" | |
647 | @end example | |
648 | ||
a9edb211 ML |
649 | By default, tests results are displayed at a file level. In order to |
650 | see the details of every individual test cases, it is possible to define | |
651 | the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example: | |
652 | ||
653 | @example | |
654 | make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no" | |
655 | @end example | |
656 | ||
ec0339cd | 657 | Upon failure, please email @email{bug-guix@@gnu.org} and attach the |
a9edb211 ML |
658 | @file{test-suite.log} file. Please specify the Guix version being used |
659 | as well as version numbers of the dependencies (@pxref{Requirements}) in | |
660 | your message. | |
ec0339cd | 661 | |
0a2f2848 LC |
662 | Guix also comes with a whole-system test suite that tests complete |
663 | GuixSD operating system instances. It can only run on systems where | |
664 | Guix is already installed, using: | |
665 | ||
666 | @example | |
667 | make check-system | |
668 | @end example | |
669 | ||
670 | @noindent | |
671 | or, again, by defining @code{TESTS} to select a subset of tests to run: | |
672 | ||
673 | @example | |
674 | make check-system TESTS="basic mcron" | |
675 | @end example | |
676 | ||
677 | These system tests are defined in the @code{(gnu tests @dots{})} | |
678 | modules. They work by running the operating systems under test with | |
679 | lightweight instrumentation in a virtual machine (VM). They can be | |
680 | computationally intensive or rather cheap, depending on whether | |
681 | substitutes are available for their dependencies (@pxref{Substitutes}). | |
682 | Some of them require a lot of storage space to hold VM images. | |
683 | ||
684 | Again in case of test failures, please send @email{bug-guix@@gnu.org} | |
685 | all the details. | |
686 | ||
bd5e766b LC |
687 | @node Setting Up the Daemon |
688 | @section Setting Up the Daemon | |
689 | ||
690 | @cindex daemon | |
691 | Operations such as building a package or running the garbage collector | |
49e6291a | 692 | are all performed by a specialized process, the @dfn{build daemon}, on |
bd5e766b LC |
693 | behalf of clients. Only the daemon may access the store and its |
694 | associated database. Thus, any operation that manipulates the store | |
695 | goes through the daemon. For instance, command-line tools such as | |
e49951eb | 696 | @command{guix package} and @command{guix build} communicate with the |
bd5e766b LC |
697 | daemon (@i{via} remote procedure calls) to instruct it what to do. |
698 | ||
49e6291a | 699 | The following sections explain how to prepare the build daemon's |
f97c9175 | 700 | environment. See also @ref{Substitutes}, for information on how to allow |
225dafde | 701 | the daemon to download pre-built binaries. |
49e6291a LC |
702 | |
703 | @menu | |
704 | * Build Environment Setup:: Preparing the isolated build environment. | |
705 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
706 | @end menu | |
707 | ||
708 | @node Build Environment Setup | |
709 | @subsection Build Environment Setup | |
710 | ||
e32171ee | 711 | @cindex build environment |
bd5e766b LC |
712 | In a standard multi-user setup, Guix and its daemon---the |
713 | @command{guix-daemon} program---are installed by the system | |
834129e0 | 714 | administrator; @file{/gnu/store} is owned by @code{root} and |
bd5e766b LC |
715 | @command{guix-daemon} runs as @code{root}. Unprivileged users may use |
716 | Guix tools to build packages or otherwise access the store, and the | |
717 | daemon will do it on their behalf, ensuring that the store is kept in a | |
718 | consistent state, and allowing built packages to be shared among users. | |
719 | ||
720 | @cindex build users | |
721 | When @command{guix-daemon} runs as @code{root}, you may not want package | |
722 | build processes themselves to run as @code{root} too, for obvious | |
723 | security reasons. To avoid that, a special pool of @dfn{build users} | |
724 | should be created for use by build processes started by the daemon. | |
725 | These build users need not have a shell and a home directory: they will | |
726 | just be used when the daemon drops @code{root} privileges in build | |
727 | processes. Having several such users allows the daemon to launch | |
728 | distinct build processes under separate UIDs, which guarantees that they | |
729 | do not interfere with each other---an essential feature since builds are | |
730 | regarded as pure functions (@pxref{Introduction}). | |
731 | ||
732 | On a GNU/Linux system, a build user pool may be created like this (using | |
733 | Bash syntax and the @code{shadow} commands): | |
734 | ||
091196b3 LC |
735 | @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html |
736 | @c for why `-G' is needed. | |
bd5e766b | 737 | @example |
cfc149dc LC |
738 | # groupadd --system guixbuild |
739 | # for i in `seq -w 1 10`; | |
bd5e766b | 740 | do |
cfc149dc LC |
741 | useradd -g guixbuild -G guixbuild \ |
742 | -d /var/empty -s `which nologin` \ | |
743 | -c "Guix build user $i" --system \ | |
744 | guixbuilder$i; | |
bd5e766b LC |
745 | done |
746 | @end example | |
747 | ||
748 | @noindent | |
54eb03ab LC |
749 | The number of build users determines how many build jobs may run in |
750 | parallel, as specified by the @option{--max-jobs} option | |
eca69fc0 LC |
751 | (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use |
752 | @command{guix system vm} and related commands, you may need to add the | |
753 | build users to the @code{kvm} group so they can access @file{/dev/kvm}, | |
754 | using @code{-G guixbuild,kvm} instead of @code{-G guixbuild} | |
755 | (@pxref{Invoking guix system}). | |
756 | ||
757 | The @code{guix-daemon} program may then be run as @code{root} with the | |
d2825c96 LC |
758 | following command@footnote{If your machine uses the systemd init system, |
759 | dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service} | |
760 | file in @file{/etc/systemd/system} will ensure that | |
ad227484 MDRS |
761 | @command{guix-daemon} is automatically started. Similarly, if your |
762 | machine uses the Upstart init system, drop the | |
763 | @file{@var{prefix}/lib/upstart/system/guix-daemon.conf} | |
764 | file in @file{/etc/init}.}: | |
bd5e766b LC |
765 | |
766 | @example | |
cfc149dc | 767 | # guix-daemon --build-users-group=guixbuild |
bd5e766b LC |
768 | @end example |
769 | ||
e900c503 | 770 | @cindex chroot |
b095792f LC |
771 | @noindent |
772 | This way, the daemon starts build processes in a chroot, under one of | |
cfc149dc | 773 | the @code{guixbuilder} users. On GNU/Linux, by default, the chroot |
6dc99317 LC |
774 | environment contains nothing but: |
775 | ||
776 | @c Keep this list in sync with libstore/build.cc! ----------------------- | |
777 | @itemize | |
778 | @item | |
4743a4da LC |
779 | a minimal @code{/dev} directory, created mostly independently from the |
780 | host @code{/dev}@footnote{``Mostly'', because while the set of files | |
781 | that appear in the chroot's @code{/dev} is fixed, most of these files | |
782 | can only be created if the host has them.}; | |
783 | ||
784 | @item | |
f97c9175 | 785 | the @code{/proc} directory; it only shows the processes of the container |
4743a4da | 786 | since a separate PID name space is used; |
6dc99317 LC |
787 | |
788 | @item | |
789 | @file{/etc/passwd} with an entry for the current user and an entry for | |
790 | user @file{nobody}; | |
791 | ||
792 | @item | |
793 | @file{/etc/group} with an entry for the user's group; | |
794 | ||
795 | @item | |
796 | @file{/etc/hosts} with an entry that maps @code{localhost} to | |
797 | @code{127.0.0.1}; | |
798 | ||
799 | @item | |
800 | a writable @file{/tmp} directory. | |
801 | @end itemize | |
b095792f | 802 | |
cb960102 ED |
803 | You can influence the directory where the daemon stores build trees |
804 | @i{via} the @code{TMPDIR} environment variable. However, the build tree | |
f97c9175 | 805 | within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0}, |
cb960102 ED |
806 | where @var{name} is the derivation name---e.g., @code{coreutils-8.24}. |
807 | This way, the value of @code{TMPDIR} does not leak inside build | |
808 | environments, which avoids discrepancies in cases where build processes | |
809 | capture the name of their build tree. | |
810 | ||
e0c941fe LC |
811 | @vindex http_proxy |
812 | The daemon also honors the @code{http_proxy} environment variable for | |
813 | HTTP downloads it performs, be it for fixed-output derivations | |
814 | (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}). | |
815 | ||
1e2644bb LC |
816 | If you are installing Guix as an unprivileged user, it is still possible |
817 | to run @command{guix-daemon} provided you pass @code{--disable-chroot}. | |
818 | However, build processes will not be isolated from one another, and not | |
819 | from the rest of the system. Thus, build processes may interfere with | |
820 | each other, and may access programs, libraries, and other files | |
821 | available on the system---making it much harder to view them as | |
822 | @emph{pure} functions. | |
bd5e766b | 823 | |
49e6291a LC |
824 | |
825 | @node Daemon Offload Setup | |
826 | @subsection Using the Offload Facility | |
827 | ||
828 | @cindex offloading | |
4ec2e92d | 829 | @cindex build hook |
21531add LC |
830 | When desired, the build daemon can @dfn{offload} derivation builds to |
831 | other machines running Guix, using the @code{offload} @dfn{build | |
832 | hook}@footnote{This feature is available only when | |
833 | @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is | |
834 | present.}. When that | |
49e6291a | 835 | feature is enabled, a list of user-specified build machines is read from |
f97c9175 | 836 | @file{/etc/guix/machines.scm}; every time a build is requested, for |
49e6291a | 837 | instance via @code{guix build}, the daemon attempts to offload it to one |
f97c9175 | 838 | of the machines that satisfy the constraints of the derivation, in |
49e6291a LC |
839 | particular its system type---e.g., @file{x86_64-linux}. Missing |
840 | prerequisites for the build are copied over SSH to the target machine, | |
841 | which then proceeds with the build; upon success the output(s) of the | |
842 | build are copied back to the initial machine. | |
843 | ||
4ec2e92d | 844 | The @file{/etc/guix/machines.scm} file typically looks like this: |
49e6291a LC |
845 | |
846 | @example | |
847 | (list (build-machine | |
848 | (name "eightysix.example.org") | |
849 | (system "x86_64-linux") | |
21531add | 850 | (host-key "ssh-ed25519 AAAAC3Nza@dots{}") |
49e6291a | 851 | (user "bob") |
21531add | 852 | (speed 2.)) ;incredibly fast! |
49e6291a LC |
853 | |
854 | (build-machine | |
855 | (name "meeps.example.org") | |
856 | (system "mips64el-linux") | |
21531add | 857 | (host-key "ssh-rsa AAAAB3Nza@dots{}") |
49e6291a LC |
858 | (user "alice") |
859 | (private-key | |
860 | (string-append (getenv "HOME") | |
21531add | 861 | "/.ssh/identity-for-guix")))) |
49e6291a LC |
862 | @end example |
863 | ||
864 | @noindent | |
865 | In the example above we specify a list of two build machines, one for | |
866 | the @code{x86_64} architecture and one for the @code{mips64el} | |
4ec2e92d LC |
867 | architecture. |
868 | ||
869 | In fact, this file is---not surprisingly!---a Scheme file that is | |
870 | evaluated when the @code{offload} hook is started. Its return value | |
871 | must be a list of @code{build-machine} objects. While this example | |
872 | shows a fixed list of build machines, one could imagine, say, using | |
873 | DNS-SD to return a list of potential build machines discovered in the | |
874 | local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using | |
c678a4ee LC |
875 | Avahi in Guile Scheme Programs}). The @code{build-machine} data type is |
876 | detailed below. | |
4ec2e92d | 877 | |
c678a4ee | 878 | @deftp {Data Type} build-machine |
f97c9175 AE |
879 | This data type represents build machines to which the daemon may offload |
880 | builds. The important fields are: | |
49e6291a LC |
881 | |
882 | @table @code | |
883 | ||
884 | @item name | |
f97c9175 | 885 | The host name of the remote machine. |
49e6291a LC |
886 | |
887 | @item system | |
f97c9175 | 888 | The system type of the remote machine---e.g., @code{"x86_64-linux"}. |
49e6291a LC |
889 | |
890 | @item user | |
891 | The user account to use when connecting to the remote machine over SSH. | |
892 | Note that the SSH key pair must @emph{not} be passphrase-protected, to | |
893 | allow non-interactive logins. | |
894 | ||
21531add LC |
895 | @item host-key |
896 | This must be the machine's SSH @dfn{public host key} in OpenSSH format. | |
897 | This is used to authenticate the machine when we connect to it. It is a | |
898 | long string that looks like this: | |
899 | ||
900 | @example | |
901 | ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org | |
902 | @end example | |
903 | ||
904 | If the machine is running the OpenSSH daemon, @command{sshd}, the host | |
905 | key can be found in a file such as | |
906 | @file{/etc/ssh/ssh_host_ed25519_key.pub}. | |
907 | ||
908 | If the machine is running the SSH daemon of GNU@tie{}lsh, | |
909 | @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a | |
910 | similar file. It can be converted to the OpenSSH format using | |
911 | @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}): | |
912 | ||
913 | @example | |
914 | $ lsh-export-key --openssh < /etc/lsh/host-key.pub | |
915 | ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{} | |
916 | @end example | |
917 | ||
49e6291a LC |
918 | @end table |
919 | ||
4ec2e92d | 920 | A number of optional fields may be specified: |
49e6291a | 921 | |
21531add | 922 | @table @asis |
49e6291a | 923 | |
21531add LC |
924 | @item @code{port} (default: @code{22}) |
925 | Port number of SSH server on the machine. | |
cecd72d5 | 926 | |
21531add LC |
927 | @item @code{private-key} (default: @file{~/.ssh/id_rsa}) |
928 | The SSH private key file to use when connecting to the machine, in | |
929 | OpenSSH format. | |
49e6291a | 930 | |
1d48cf94 LC |
931 | @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"}) |
932 | @itemx @code{compression-level} (default: @code{3}) | |
933 | The SSH-level compression methods and compression level requested. | |
934 | ||
935 | Note that offloading relies on SSH compression to reduce bandwidth usage | |
936 | when transferring files to and from build machines. | |
937 | ||
cf283dd9 LC |
938 | @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"}) |
939 | File name of the Unix-domain socket @command{guix-daemon} is listening | |
940 | to on that machine. | |
c4fdfd6f | 941 | |
21531add LC |
942 | @item @code{parallel-builds} (default: @code{1}) |
943 | The number of builds that may run in parallel on the machine. | |
49e6291a | 944 | |
21531add | 945 | @item @code{speed} (default: @code{1.0}) |
49e6291a LC |
946 | A ``relative speed factor''. The offload scheduler will tend to prefer |
947 | machines with a higher speed factor. | |
948 | ||
21531add | 949 | @item @code{features} (default: @code{'()}) |
49e6291a LC |
950 | A list of strings denoting specific features supported by the machine. |
951 | An example is @code{"kvm"} for machines that have the KVM Linux modules | |
952 | and corresponding hardware support. Derivations can request features by | |
953 | name, and they will be scheduled on matching build machines. | |
954 | ||
955 | @end table | |
c678a4ee | 956 | @end deftp |
49e6291a | 957 | |
aebaee95 LC |
958 | The @code{guile} command must be in the search path on the build |
959 | machines. In addition, the Guix modules must be in | |
c4fdfd6f LC |
960 | @code{$GUILE_LOAD_PATH} on the build machine---you can check whether |
961 | this is the case by running: | |
962 | ||
963 | @example | |
21531add | 964 | ssh build-machine guile -c "'(use-modules (guix config))'" |
c4fdfd6f | 965 | @end example |
49e6291a | 966 | |
f97c9175 | 967 | There is one last thing to do once @file{machines.scm} is in place. As |
49e6291a | 968 | explained above, when offloading, files are transferred back and forth |
c4fdfd6f LC |
969 | between the machine stores. For this to work, you first need to |
970 | generate a key pair on each machine to allow the daemon to export signed | |
971 | archives of files from the store (@pxref{Invoking guix archive}): | |
49e6291a LC |
972 | |
973 | @example | |
974 | # guix archive --generate-key | |
975 | @end example | |
976 | ||
977 | @noindent | |
c4fdfd6f LC |
978 | Each build machine must authorize the key of the master machine so that |
979 | it accepts store items it receives from the master: | |
980 | ||
981 | @example | |
982 | # guix archive --authorize < master-public-key.txt | |
983 | @end example | |
984 | ||
985 | @noindent | |
986 | Likewise, the master machine must authorize the key of each build machine. | |
987 | ||
988 | All the fuss with keys is here to express pairwise mutual trust | |
989 | relations between the master and the build machines. Concretely, when | |
990 | the master receives files from a build machine (and @i{vice versa}), its | |
991 | build daemon can make sure they are genuine, have not been tampered | |
992 | with, and that they are signed by an authorized key. | |
49e6291a | 993 | |
aebaee95 LC |
994 | @cindex offload test |
995 | To test whether your setup is operational, run this command on the | |
996 | master node: | |
997 | ||
998 | @example | |
999 | # guix offload test | |
1000 | @end example | |
1001 | ||
1002 | This will attempt to connect to each of the build machines specified in | |
1003 | @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are | |
1004 | available on each machine, attempt to export to the machine and import | |
1005 | from it, and report any error in the process. | |
1006 | ||
1007 | If you want to test a different machine file, just specify it on the | |
1008 | command line: | |
1009 | ||
1010 | @example | |
1011 | # guix offload test machines-qualif.scm | |
1012 | @end example | |
1013 | ||
27991c97 LC |
1014 | Last, you can test the subset of the machines whose name matches a |
1015 | regular expression like this: | |
1016 | ||
1017 | @example | |
1018 | # guix offload test machines.scm '\.gnu\.org$' | |
1019 | @end example | |
49e6291a | 1020 | |
bd5e766b LC |
1021 | @node Invoking guix-daemon |
1022 | @section Invoking @command{guix-daemon} | |
1023 | ||
1024 | The @command{guix-daemon} program implements all the functionality to | |
1025 | access the store. This includes launching build processes, running the | |
1026 | garbage collector, querying the availability of a build result, etc. It | |
1027 | is normally run as @code{root} like this: | |
1028 | ||
1029 | @example | |
cfc149dc | 1030 | # guix-daemon --build-users-group=guixbuild |
bd5e766b LC |
1031 | @end example |
1032 | ||
1033 | @noindent | |
081145cf | 1034 | For details on how to set it up, @pxref{Setting Up the Daemon}. |
bd5e766b | 1035 | |
e900c503 LC |
1036 | @cindex chroot |
1037 | @cindex container, build environment | |
1038 | @cindex build environment | |
1039 | @cindex reproducible builds | |
bd5e766b LC |
1040 | By default, @command{guix-daemon} launches build processes under |
1041 | different UIDs, taken from the build group specified with | |
1042 | @code{--build-users-group}. In addition, each build process is run in a | |
1043 | chroot environment that only contains the subset of the store that the | |
1044 | build process depends on, as specified by its derivation | |
1045 | (@pxref{Programming Interface, derivation}), plus a set of specific | |
1046 | system directories. By default, the latter contains @file{/dev} and | |
e900c503 LC |
1047 | @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a |
1048 | @dfn{container}: in addition to having its own file system tree, it has | |
1049 | a separate mount name space, its own PID name space, network name space, | |
1050 | etc. This helps achieve reproducible builds (@pxref{Features}). | |
bd5e766b | 1051 | |
cbc538fe LC |
1052 | When the daemon performs a build on behalf of the user, it creates a |
1053 | build directory under @file{/tmp} or under the directory specified by | |
1054 | its @code{TMPDIR} environment variable; this directory is shared with | |
1055 | the container for the duration of the build. Be aware that using a | |
1056 | directory other than @file{/tmp} can affect build results---for example, | |
1057 | with a longer directory name, a build process that uses Unix-domain | |
1058 | sockets might hit the name length limitation for @code{sun_path}, which | |
1059 | it would otherwise not hit. | |
1060 | ||
1061 | The build directory is automatically deleted upon completion, unless the | |
1062 | build failed and the client specified @option{--keep-failed} | |
1063 | (@pxref{Invoking guix build, @option{--keep-failed}}). | |
1064 | ||
bd5e766b LC |
1065 | The following command-line options are supported: |
1066 | ||
1067 | @table @code | |
1068 | @item --build-users-group=@var{group} | |
1069 | Take users from @var{group} to run build processes (@pxref{Setting Up | |
1070 | the Daemon, build users}). | |
1071 | ||
6858f9d1 | 1072 | @item --no-substitutes |
b5385b52 | 1073 | @cindex substitutes |
6858f9d1 | 1074 | Do not use substitutes for build products. That is, always build things |
c4202d60 LC |
1075 | locally instead of allowing downloads of pre-built binaries |
1076 | (@pxref{Substitutes}). | |
6858f9d1 | 1077 | |
b5385b52 LC |
1078 | By default substitutes are used, unless the client---such as the |
1079 | @command{guix package} command---is explicitly invoked with | |
1080 | @code{--no-substitutes}. | |
1081 | ||
1082 | When the daemon runs with @code{--no-substitutes}, clients can still | |
1083 | explicitly enable substitution @i{via} the @code{set-build-options} | |
1084 | remote procedure call (@pxref{The Store}). | |
1085 | ||
9176607e | 1086 | @item --substitute-urls=@var{urls} |
f8a8e0fe | 1087 | @anchor{daemon-substitute-urls} |
9176607e | 1088 | Consider @var{urls} the default whitespace-separated list of substitute |
df061d07 LC |
1089 | source URLs. When this option is omitted, |
1090 | @indicateurl{https://mirror.hydra.gnu.org https://hydra.gnu.org} is used | |
1091 | (@code{mirror.hydra.gnu.org} is a mirror of @code{hydra.gnu.org}). | |
9176607e LC |
1092 | |
1093 | This means that substitutes may be downloaded from @var{urls}, as long | |
1094 | as they are signed by a trusted signature (@pxref{Substitutes}). | |
1095 | ||
4ec2e92d LC |
1096 | @cindex build hook |
1097 | @item --no-build-hook | |
1098 | Do not use the @dfn{build hook}. | |
1099 | ||
1100 | The build hook is a helper program that the daemon can start and to | |
1101 | which it submits build requests. This mechanism is used to offload | |
1102 | builds to other machines (@pxref{Daemon Offload Setup}). | |
1103 | ||
bd5e766b LC |
1104 | @item --cache-failures |
1105 | Cache build failures. By default, only successful builds are cached. | |
1106 | ||
30d9aa54 LC |
1107 | When this option is used, @command{guix gc --list-failures} can be used |
1108 | to query the set of store items marked as failed; @command{guix gc | |
1109 | --clear-failures} removes store items from the set of cached failures. | |
1110 | @xref{Invoking guix gc}. | |
1111 | ||
bd5e766b LC |
1112 | @item --cores=@var{n} |
1113 | @itemx -c @var{n} | |
1114 | Use @var{n} CPU cores to build each derivation; @code{0} means as many | |
1115 | as available. | |
1116 | ||
6efc160e | 1117 | The default value is @code{0}, but it may be overridden by clients, such |
e49951eb MW |
1118 | as the @code{--cores} option of @command{guix build} (@pxref{Invoking |
1119 | guix build}). | |
bd5e766b LC |
1120 | |
1121 | The effect is to define the @code{NIX_BUILD_CORES} environment variable | |
1122 | in the build process, which can then use it to exploit internal | |
1123 | parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}. | |
1124 | ||
1125 | @item --max-jobs=@var{n} | |
1126 | @itemx -M @var{n} | |
1127 | Allow at most @var{n} build jobs in parallel. The default value is | |
f6526eb3 LC |
1128 | @code{1}. Setting it to @code{0} means that no builds will be performed |
1129 | locally; instead, the daemon will offload builds (@pxref{Daemon Offload | |
1130 | Setup}), or simply fail. | |
bd5e766b | 1131 | |
ecf84b7c LC |
1132 | @item --rounds=@var{N} |
1133 | Build each derivation @var{n} times in a row, and raise an error if | |
1134 | consecutive build results are not bit-for-bit identical. Note that this | |
1135 | setting can be overridden by clients such as @command{guix build} | |
1136 | (@pxref{Invoking guix build}). | |
1137 | ||
b4528110 ED |
1138 | When used in conjunction with @option{--keep-failed}, the differing |
1139 | output is kept in the store, under @file{/gnu/store/@dots{}-check}. | |
1140 | This makes it easy to look for differences between the two results. | |
1141 | ||
bd5e766b LC |
1142 | @item --debug |
1143 | Produce debugging output. | |
1144 | ||
1145 | This is useful to debug daemon start-up issues, but then it may be | |
1146 | overridden by clients, for example the @code{--verbosity} option of | |
e49951eb | 1147 | @command{guix build} (@pxref{Invoking guix build}). |
bd5e766b LC |
1148 | |
1149 | @item --chroot-directory=@var{dir} | |
1150 | Add @var{dir} to the build chroot. | |
1151 | ||
1152 | Doing this may change the result of build processes---for instance if | |
1153 | they use optional dependencies found in @var{dir} when it is available, | |
1154 | and not otherwise. For that reason, it is not recommended to do so. | |
1155 | Instead, make sure that each derivation declares all the inputs that it | |
1156 | needs. | |
1157 | ||
1158 | @item --disable-chroot | |
1159 | Disable chroot builds. | |
1160 | ||
1161 | Using this option is not recommended since, again, it would allow build | |
1e2644bb LC |
1162 | processes to gain access to undeclared dependencies. It is necessary, |
1163 | though, when @command{guix-daemon} is running under an unprivileged user | |
1164 | account. | |
bd5e766b LC |
1165 | |
1166 | @item --disable-log-compression | |
1167 | Disable compression of the build logs. | |
1168 | ||
1da983b9 LC |
1169 | Unless @code{--lose-logs} is used, all the build logs are kept in the |
1170 | @var{localstatedir}. To save space, the daemon automatically compresses | |
1171 | them with bzip2 by default. This option disables that. | |
1172 | ||
ab3893d7 LC |
1173 | @item --disable-deduplication |
1174 | @cindex deduplication | |
bd5e766b LC |
1175 | Disable automatic file ``deduplication'' in the store. |
1176 | ||
1da983b9 | 1177 | By default, files added to the store are automatically ``deduplicated'': |
ab3893d7 LC |
1178 | if a newly added file is identical to another one found in the store, |
1179 | the daemon makes the new file a hard link to the other file. This can | |
4988dd40 | 1180 | noticeably reduce disk usage, at the expense of slightly increased |
ab3893d7 LC |
1181 | input/output load at the end of a build process. This option disables |
1182 | this optimization. | |
1da983b9 | 1183 | |
6e37066e LC |
1184 | @item --gc-keep-outputs[=yes|no] |
1185 | Tell whether the garbage collector (GC) must keep outputs of live | |
1186 | derivations. | |
1187 | ||
1188 | When set to ``yes'', the GC will keep the outputs of any live derivation | |
1189 | available in the store---the @code{.drv} files. The default is ``no'', | |
1190 | meaning that derivation outputs are kept only if they are GC roots. | |
1191 | ||
1192 | @item --gc-keep-derivations[=yes|no] | |
1193 | Tell whether the garbage collector (GC) must keep derivations | |
1194 | corresponding to live outputs. | |
1195 | ||
1196 | When set to ``yes'', as is the case by default, the GC keeps | |
1197 | derivations---i.e., @code{.drv} files---as long as at least one of their | |
1198 | outputs is live. This allows users to keep track of the origins of | |
1199 | items in their store. Setting it to ``no'' saves a bit of disk space. | |
1200 | ||
1201 | Note that when both @code{--gc-keep-derivations} and | |
1202 | @code{--gc-keep-outputs} are used, the effect is to keep all the build | |
1203 | prerequisites (the sources, compiler, libraries, and other build-time | |
1204 | tools) of live objects in the store, regardless of whether these | |
1205 | prerequisites are live. This is convenient for developers since it | |
1206 | saves rebuilds or downloads. | |
1207 | ||
bd5e766b LC |
1208 | @item --impersonate-linux-2.6 |
1209 | On Linux-based systems, impersonate Linux 2.6. This means that the | |
1210 | kernel's @code{uname} system call will report 2.6 as the release number. | |
1211 | ||
1212 | This might be helpful to build programs that (usually wrongfully) depend | |
1213 | on the kernel version number. | |
1214 | ||
1215 | @item --lose-logs | |
1216 | Do not keep build logs. By default they are kept under | |
ce33631f | 1217 | @code{@var{localstatedir}/guix/log}. |
bd5e766b LC |
1218 | |
1219 | @item --system=@var{system} | |
1220 | Assume @var{system} as the current system type. By default it is the | |
1221 | architecture/kernel pair found at configure time, such as | |
1222 | @code{x86_64-linux}. | |
b8d2aa26 LC |
1223 | |
1224 | @item --listen=@var{socket} | |
1225 | Listen for connections on @var{socket}, the file name of a Unix-domain | |
1226 | socket. The default socket is | |
1227 | @file{@var{localstatedir}/daemon-socket/socket}. This option is only | |
1228 | useful in exceptional circumstances, such as if you need to run several | |
1229 | daemons on the same machine. | |
bd5e766b LC |
1230 | @end table |
1231 | ||
1232 | ||
0e2d0213 LC |
1233 | @node Application Setup |
1234 | @section Application Setup | |
1235 | ||
d23ef788 | 1236 | @cindex foreign distro |
85e57214 LC |
1237 | When using Guix on top of GNU/Linux distribution other than GuixSD---a |
1238 | so-called @dfn{foreign distro}---a few additional steps are needed to | |
1239 | get everything in place. Here are some of them. | |
0e2d0213 LC |
1240 | |
1241 | @subsection Locales | |
1242 | ||
5c3c1427 | 1243 | @anchor{locales-and-locpath} |
0e2d0213 | 1244 | @cindex locales, when not on GuixSD |
5c3c1427 | 1245 | @vindex LOCPATH |
85e57214 | 1246 | @vindex GUIX_LOCPATH |
f97c9175 AE |
1247 | Packages installed @i{via} Guix will not use the locale data of the |
1248 | host system. Instead, you must first install one of the locale packages | |
85e57214 LC |
1249 | available with Guix and then define the @code{GUIX_LOCPATH} environment |
1250 | variable: | |
0e2d0213 LC |
1251 | |
1252 | @example | |
1253 | $ guix package -i glibc-locales | |
85e57214 | 1254 | $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale |
0e2d0213 LC |
1255 | @end example |
1256 | ||
1257 | Note that the @code{glibc-locales} package contains data for all the | |
1258 | locales supported by the GNU@tie{}libc and weighs in at around | |
f97c9175 | 1259 | 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but |
0e2d0213 LC |
1260 | limited to a few UTF-8 locales. |
1261 | ||
85e57214 LC |
1262 | The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH} |
1263 | (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference | |
1264 | Manual}). There are two important differences though: | |
1265 | ||
1266 | @enumerate | |
1267 | @item | |
f97c9175 | 1268 | @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc |
85e57214 | 1269 | provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you |
f97c9175 | 1270 | to make sure the programs of the foreign distro will not end up loading |
85e57214 LC |
1271 | incompatible locale data. |
1272 | ||
1273 | @item | |
1274 | libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where | |
1275 | @code{X.Y} is the libc version---e.g., @code{2.22}. This means that, | |
1276 | should your Guix profile contain a mixture of programs linked against | |
1277 | different libc version, each libc version will only try to load locale | |
1278 | data in the right format. | |
1279 | @end enumerate | |
1280 | ||
1281 | This is important because the locale data format used by different libc | |
1282 | versions may be incompatible. | |
1283 | ||
9a5187b6 LC |
1284 | @subsection Name Service Switch |
1285 | ||
1286 | @cindex name service switch, glibc | |
1287 | @cindex NSS (name service switch), glibc | |
1288 | @cindex nscd (name service caching daemon) | |
1289 | @cindex name service caching daemon (nscd) | |
1290 | When using Guix on a foreign distro, we @emph{strongly recommend} that | |
1291 | the system run the GNU C library's @dfn{name service cache daemon}, | |
1292 | @command{nscd}, which should be listening on the | |
1293 | @file{/var/run/nscd/socket} socket. Failing to do that, applications | |
1294 | installed with Guix may fail to look up host names or user accounts, or | |
1295 | may even crash. The next paragraphs explain why. | |
1296 | ||
1297 | @cindex @file{nsswitch.conf} | |
1298 | The GNU C library implements a @dfn{name service switch} (NSS), which is | |
1299 | an extensible mechanism for ``name lookups'' in general: host name | |
1300 | resolution, user accounts, and more (@pxref{Name Service Switch,,, libc, | |
1301 | The GNU C Library Reference Manual}). | |
1302 | ||
1303 | @cindex Network information service (NIS) | |
1304 | @cindex NIS (Network information service) | |
1305 | Being extensible, the NSS supports @dfn{plugins}, which provide new name | |
1306 | lookup implementations: for example, the @code{nss-mdns} plugin allow | |
1307 | resolution of @code{.local} host names, the @code{nis} plugin allows | |
1308 | user account lookup using the Network information service (NIS), and so | |
1309 | on. These extra ``lookup services'' are configured system-wide in | |
1310 | @file{/etc/nsswitch.conf}, and all the programs running on the system | |
1311 | honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C | |
1312 | Reference Manual}). | |
1313 | ||
1314 | When they perform a name lookup---for instance by calling the | |
1315 | @code{getaddrinfo} function in C---applications first try to connect to | |
1316 | the nscd; on success, nscd performs name lookups on their behalf. If | |
1317 | the nscd is not running, then they perform the name lookup by | |
1318 | themselves, by loading the name lookup services into their own address | |
1319 | space and running it. These name lookup services---the | |
1320 | @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from | |
1321 | the host system's C library, rather than from the C library the | |
1322 | application is linked against (the C library coming from Guix). | |
1323 | ||
1324 | And this is where the problem is: if your application is linked against | |
1325 | Guix's C library (say, glibc 2.24) and tries to load NSS plugins from | |
1326 | another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will | |
1327 | likely crash or have its name lookups fail unexpectedly. | |
1328 | ||
1329 | Running @command{nscd} on the system, among other advantages, eliminates | |
1330 | this binary incompatibility problem because those @code{libnss_*.so} | |
1331 | files are loaded in the @command{nscd} process, not in applications | |
1332 | themselves. | |
1333 | ||
0e2d0213 LC |
1334 | @subsection X11 Fonts |
1335 | ||
e32171ee | 1336 | @cindex fonts |
4988dd40 | 1337 | The majority of graphical applications use Fontconfig to locate and |
f97c9175 AE |
1338 | load fonts and perform X11-client-side rendering. The @code{fontconfig} |
1339 | package in Guix looks for fonts in @file{$HOME/.guix-profile} | |
0e2d0213 | 1340 | by default. Thus, to allow graphical applications installed with Guix |
f97c9175 | 1341 | to display fonts, you have to install fonts with Guix as well. |
0e2d0213 | 1342 | Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and |
8fe5b1d1 | 1343 | @code{font-gnu-freefont-ttf}. |
0e2d0213 | 1344 | |
5c36edc8 LC |
1345 | To display text written in Chinese languages, Japanese, or Korean in |
1346 | graphical applications, consider installing | |
1347 | @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former | |
1348 | has multiple outputs, one per language family (@pxref{Packages with | |
1349 | Multiple Outputs}). For instance, the following command installs fonts | |
1350 | for Chinese languages: | |
1351 | ||
1352 | @example | |
1353 | guix package -i font-adobe-source-han-sans:cn | |
1354 | @end example | |
1355 | ||
e32171ee | 1356 | @cindex @code{xterm} |
1a3e6b15 AK |
1357 | Older programs such as @command{xterm} do not use Fontconfig and instead |
1358 | rely on server-side font rendering. Such programs require to specify a | |
1359 | full name of a font using XLFD (X Logical Font Description), like this: | |
1360 | ||
1361 | @example | |
1362 | -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1 | |
1363 | @end example | |
1364 | ||
1365 | To be able to use such full names for the TrueType fonts installed in | |
1366 | your Guix profile, you need to extend the font path of the X server: | |
1367 | ||
1368 | @example | |
1369 | xset +fp ~/.guix-profile/share/fonts/truetype | |
1370 | @end example | |
1371 | ||
e32171ee | 1372 | @cindex @code{xlsfonts} |
1a3e6b15 AK |
1373 | After that, you can run @code{xlsfonts} (from @code{xlsfonts} package) |
1374 | to make sure your TrueType fonts are listed there. | |
1375 | ||
b3129f2b LC |
1376 | @subsection X.509 Certificates |
1377 | ||
e32171ee | 1378 | @cindex @code{nss-certs} |
b3129f2b LC |
1379 | The @code{nss-certs} package provides X.509 certificates, which allow |
1380 | programs to authenticate Web servers accessed over HTTPS. | |
1381 | ||
1382 | When using Guix on a foreign distro, you can install this package and | |
1383 | define the relevant environment variables so that packages know where to | |
80d944b7 | 1384 | look for certificates. @xref{X.509 Certificates}, for detailed |
b3129f2b LC |
1385 | information. |
1386 | ||
6d97319c AK |
1387 | @subsection Emacs Packages |
1388 | ||
e32171ee | 1389 | @cindex @code{emacs} |
6d97319c AK |
1390 | When you install Emacs packages with Guix, the elisp files may be placed |
1391 | either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in | |
1392 | sub-directories of | |
1393 | @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter | |
1394 | directory exists because potentially there may exist thousands of Emacs | |
1395 | packages and storing all their files in a single directory may be not | |
1396 | reliable (because of name conflicts). So we think using a separate | |
1397 | directory for each package is a good idea. It is very similar to how | |
1398 | the Emacs package system organizes the file structure (@pxref{Package | |
1399 | Files,,, emacs, The GNU Emacs Manual}). | |
1400 | ||
1401 | By default, Emacs (installed with Guix) ``knows'' where these packages | |
f97c9175 | 1402 | are placed, so you do not need to perform any configuration. If, for |
6d97319c | 1403 | some reason, you want to avoid auto-loading Emacs packages installed |
f97c9175 | 1404 | with Guix, you can do so by running Emacs with @code{--no-site-file} |
6d97319c AK |
1405 | option (@pxref{Init File,,, emacs, The GNU Emacs Manual}). |
1406 | ||
0e2d0213 LC |
1407 | @c TODO What else? |
1408 | ||
eeaf4427 LC |
1409 | @c ********************************************************************* |
1410 | @node Package Management | |
1411 | @chapter Package Management | |
1412 | ||
e32171ee | 1413 | @cindex packages |
f8348b91 | 1414 | The purpose of GNU Guix is to allow users to easily install, upgrade, and |
eeaf4427 | 1415 | remove software packages, without having to know about their build |
f97c9175 | 1416 | procedures or dependencies. Guix also goes beyond this obvious set of |
eeaf4427 LC |
1417 | features. |
1418 | ||
1419 | This chapter describes the main features of Guix, as well as the package | |
deb6276d AK |
1420 | management tools it provides. Along with the command-line interface |
1421 | described below (@pxref{Invoking guix package, @code{guix package}}), | |
1422 | you may also use Emacs Interface, after installing @code{emacs-guix} | |
1423 | package (run @kbd{M-x guix-help} command to start with it): | |
1424 | ||
1425 | @example | |
1426 | guix package -i emacs-guix | |
1427 | @end example | |
eeaf4427 LC |
1428 | |
1429 | @menu | |
1430 | * Features:: How Guix will make your life brighter. | |
e49951eb | 1431 | * Invoking guix package:: Package installation, removal, etc. |
c4202d60 | 1432 | * Substitutes:: Downloading pre-built binaries. |
760c60d6 | 1433 | * Packages with Multiple Outputs:: Single source package, multiple outputs. |
e49951eb | 1434 | * Invoking guix gc:: Running the garbage collector. |
f651b477 | 1435 | * Invoking guix pull:: Fetching the latest Guix and distribution. |
239c2266 | 1436 | * Invoking guix pack:: Creating software bundles. |
760c60d6 | 1437 | * Invoking guix archive:: Exporting and importing store files. |
eeaf4427 LC |
1438 | @end menu |
1439 | ||
1440 | @node Features | |
1441 | @section Features | |
1442 | ||
1443 | When using Guix, each package ends up in the @dfn{package store}, in its | |
1444 | own directory---something that resembles | |
deb6276d | 1445 | @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string. |
eeaf4427 LC |
1446 | |
1447 | Instead of referring to these directories, users have their own | |
1448 | @dfn{profile}, which points to the packages that they actually want to | |
821b0015 LC |
1449 | use. These profiles are stored within each user's home directory, at |
1450 | @code{$HOME/.guix-profile}. | |
eeaf4427 | 1451 | |
821b0015 | 1452 | For example, @code{alice} installs GCC 4.7.2. As a result, |
eeaf4427 | 1453 | @file{/home/alice/.guix-profile/bin/gcc} points to |
834129e0 | 1454 | @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine, |
821b0015 LC |
1455 | @code{bob} had already installed GCC 4.8.0. The profile of @code{bob} |
1456 | simply continues to point to | |
834129e0 | 1457 | @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC |
821b0015 | 1458 | coexist on the same system without any interference. |
eeaf4427 | 1459 | |
e49951eb | 1460 | The @command{guix package} command is the central tool to manage |
f97c9175 | 1461 | packages (@pxref{Invoking guix package}). It operates on the per-user |
821b0015 | 1462 | profiles, and can be used @emph{with normal user privileges}. |
eeaf4427 | 1463 | |
e32171ee | 1464 | @cindex transactions |
eeaf4427 LC |
1465 | The command provides the obvious install, remove, and upgrade |
1466 | operations. Each invocation is actually a @emph{transaction}: either | |
ba55b1cb | 1467 | the specified operation succeeds, or nothing happens. Thus, if the |
e49951eb | 1468 | @command{guix package} process is terminated during the transaction, |
eeaf4427 LC |
1469 | or if a power outage occurs during the transaction, then the user's |
1470 | profile remains in its previous state, and remains usable. | |
1471 | ||
1472 | In addition, any package transaction may be @emph{rolled back}. So, if, | |
1473 | for example, an upgrade installs a new version of a package that turns | |
1474 | out to have a serious bug, users may roll back to the previous instance | |
4af2447e | 1475 | of their profile, which was known to work well. Similarly, the global |
6f773606 LC |
1476 | system configuration on GuixSD is subject to |
1477 | transactional upgrades and roll-back | |
4af2447e | 1478 | (@pxref{Using the Configuration System}). |
eeaf4427 | 1479 | |
f97c9175 AE |
1480 | All packages in the package store may be @emph{garbage-collected}. |
1481 | Guix can determine which packages are still referenced by user | |
fe8ff028 | 1482 | profiles, and remove those that are provably no longer referenced |
e49951eb | 1483 | (@pxref{Invoking guix gc}). Users may also explicitly remove old |
fe8ff028 LC |
1484 | generations of their profile so that the packages they refer to can be |
1485 | collected. | |
eeaf4427 | 1486 | |
e900c503 LC |
1487 | @cindex reproducibility |
1488 | @cindex reproducible builds | |
eeaf4427 LC |
1489 | Finally, Guix takes a @dfn{purely functional} approach to package |
1490 | management, as described in the introduction (@pxref{Introduction}). | |
834129e0 | 1491 | Each @file{/gnu/store} package directory name contains a hash of all the |
eeaf4427 LC |
1492 | inputs that were used to build that package---compiler, libraries, build |
1493 | scripts, etc. This direct correspondence allows users to make sure a | |
1494 | given package installation matches the current state of their | |
e900c503 LC |
1495 | distribution. It also helps maximize @dfn{build reproducibility}: |
1496 | thanks to the isolated build environments that are used, a given build | |
1497 | is likely to yield bit-identical files when performed on different | |
1498 | machines (@pxref{Invoking guix-daemon, container}). | |
eeaf4427 | 1499 | |
c4202d60 | 1500 | @cindex substitutes |
eeaf4427 | 1501 | This foundation allows Guix to support @dfn{transparent binary/source |
c4202d60 | 1502 | deployment}. When a pre-built binary for a @file{/gnu/store} item is |
18f2887b | 1503 | available from an external source---a @dfn{substitute}, Guix just |
c4202d60 LC |
1504 | downloads it and unpacks it; |
1505 | otherwise, it builds the package from source, locally | |
bf9eacd2 LC |
1506 | (@pxref{Substitutes}). Because build results are usually bit-for-bit |
1507 | reproducible, users do not have to trust servers that provide | |
1508 | substitutes: they can force a local build and @emph{challenge} providers | |
1509 | (@pxref{Invoking guix challenge}). | |
eeaf4427 | 1510 | |
f5fd4fd2 LC |
1511 | Control over the build environment is a feature that is also useful for |
1512 | developers. The @command{guix environment} command allows developers of | |
1513 | a package to quickly set up the right development environment for their | |
f97c9175 AE |
1514 | package, without having to manually install the dependencies of the |
1515 | package into their profile (@pxref{Invoking guix environment}). | |
f5fd4fd2 | 1516 | |
e49951eb MW |
1517 | @node Invoking guix package |
1518 | @section Invoking @command{guix package} | |
eeaf4427 | 1519 | |
e32171ee JD |
1520 | @cindex installing packages |
1521 | @cindex removing packages | |
1522 | @cindex package installation | |
1523 | @cindex package removal | |
e49951eb | 1524 | The @command{guix package} command is the tool that allows users to |
eeaf4427 LC |
1525 | install, upgrade, and remove packages, as well as rolling back to |
1526 | previous configurations. It operates only on the user's own profile, | |
1527 | and works with normal user privileges (@pxref{Features}). Its syntax | |
1528 | is: | |
1529 | ||
1530 | @example | |
e49951eb | 1531 | guix package @var{options} |
eeaf4427 | 1532 | @end example |
e32171ee | 1533 | @cindex transactions |
ba55b1cb | 1534 | Primarily, @var{options} specifies the operations to be performed during |
eeaf4427 | 1535 | the transaction. Upon completion, a new profile is created, but |
99bd74d5 | 1536 | previous @dfn{generations} of the profile remain available, should the user |
eeaf4427 LC |
1537 | want to roll back. |
1538 | ||
6447738c MW |
1539 | For example, to remove @code{lua} and install @code{guile} and |
1540 | @code{guile-cairo} in a single transaction: | |
1541 | ||
1542 | @example | |
1543 | guix package -r lua -i guile guile-cairo | |
1544 | @end example | |
1545 | ||
99bd74d5 LC |
1546 | @command{guix package} also supports a @dfn{declarative approach} |
1547 | whereby the user specifies the exact set of packages to be available and | |
1548 | passes it @i{via} the @option{--manifest} option | |
1549 | (@pxref{profile-manifest, @option{--manifest}}). | |
1550 | ||
e32171ee | 1551 | @cindex profile |
b9e5c0a9 | 1552 | For each user, a symlink to the user's default profile is automatically |
0ec1af59 | 1553 | created in @file{$HOME/.guix-profile}. This symlink always points to the |
b9e5c0a9 LC |
1554 | current generation of the user's default profile. Thus, users can add |
1555 | @file{$HOME/.guix-profile/bin} to their @code{PATH} environment | |
1556 | variable, and so on. | |
d664f1b4 LC |
1557 | @cindex search paths |
1558 | If you are not using the Guix System Distribution, consider adding the | |
1559 | following lines to your @file{~/.bash_profile} (@pxref{Bash Startup | |
1560 | Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned | |
1561 | shells get all the right environment variable definitions: | |
1562 | ||
1563 | @example | |
1564 | GUIX_PROFILE="$HOME/.guix-profile" \ | |
1565 | source "$HOME/.guix-profile/etc/profile" | |
1566 | @end example | |
b9e5c0a9 | 1567 | |
4379c35b LC |
1568 | In a multi-user setup, user profiles are stored in a place registered as |
1569 | a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points | |
1570 | to (@pxref{Invoking guix gc}). That directory is normally | |
0ec1af59 LC |
1571 | @code{@var{localstatedir}/profiles/per-user/@var{user}}, where |
1572 | @var{localstatedir} is the value passed to @code{configure} as | |
4379c35b LC |
1573 | @code{--localstatedir}, and @var{user} is the user name. The |
1574 | @file{per-user} directory is created when @command{guix-daemon} is | |
1575 | started, and the @var{user} sub-directory is created by @command{guix | |
1576 | package}. | |
0ec1af59 LC |
1577 | |
1578 | The @var{options} can be among the following: | |
1579 | ||
eeaf4427 LC |
1580 | @table @code |
1581 | ||
6447738c MW |
1582 | @item --install=@var{package} @dots{} |
1583 | @itemx -i @var{package} @dots{} | |
1584 | Install the specified @var{package}s. | |
eeaf4427 | 1585 | |
6447738c | 1586 | Each @var{package} may specify either a simple package name, such as |
1b846da8 ML |
1587 | @code{guile}, or a package name followed by an at-sign and version number, |
1588 | such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter | |
724311a2 LC |
1589 | case, the newest version prefixed by @code{1.8} is selected.) |
1590 | ||
1591 | If no version number is specified, the | |
dc5669cd MW |
1592 | newest available version will be selected. In addition, @var{package} |
1593 | may contain a colon, followed by the name of one of the outputs of the | |
1b846da8 | 1594 | package, as in @code{gcc:doc} or @code{binutils@@2.22:lib} |
e7f34eb0 LC |
1595 | (@pxref{Packages with Multiple Outputs}). Packages with a corresponding |
1596 | name (and optionally version) are searched for among the GNU | |
1597 | distribution modules (@pxref{Package Modules}). | |
eeaf4427 | 1598 | |
461572cc LC |
1599 | @cindex propagated inputs |
1600 | Sometimes packages have @dfn{propagated inputs}: these are dependencies | |
21461f27 LC |
1601 | that automatically get installed along with the required package |
1602 | (@pxref{package-propagated-inputs, @code{propagated-inputs} in | |
1603 | @code{package} objects}, for information about propagated inputs in | |
1604 | package definitions). | |
461572cc | 1605 | |
21461f27 | 1606 | @anchor{package-cmd-propagated-inputs} |
461572cc LC |
1607 | An example is the GNU MPC library: its C header files refer to those of |
1608 | the GNU MPFR library, which in turn refer to those of the GMP library. | |
1609 | Thus, when installing MPC, the MPFR and GMP libraries also get installed | |
1610 | in the profile; removing MPC also removes MPFR and GMP---unless they had | |
f97c9175 | 1611 | also been explicitly installed by the user. |
461572cc | 1612 | |
ba7ea5ce | 1613 | Besides, packages sometimes rely on the definition of environment |
5924080d | 1614 | variables for their search paths (see explanation of |
ba7ea5ce | 1615 | @code{--search-paths} below). Any missing or possibly incorrect |
5924080d LC |
1616 | environment variable definitions are reported here. |
1617 | ||
5d4b411f LC |
1618 | @item --install-from-expression=@var{exp} |
1619 | @itemx -e @var{exp} | |
1620 | Install the package @var{exp} evaluates to. | |
1621 | ||
1622 | @var{exp} must be a Scheme expression that evaluates to a | |
1623 | @code{<package>} object. This option is notably useful to disambiguate | |
1624 | between same-named variants of a package, with expressions such as | |
1625 | @code{(@@ (gnu packages base) guile-final)}. | |
1626 | ||
1627 | Note that this option installs the first output of the specified | |
1628 | package, which may be insufficient when needing a specific output of a | |
1629 | multiple-output package. | |
1630 | ||
0d279400 DT |
1631 | @item --install-from-file=@var{file} |
1632 | @itemx -f @var{file} | |
1633 | Install the package that the code within @var{file} evaluates to. | |
1634 | ||
1635 | As an example, @var{file} might contain a definition like this | |
1636 | (@pxref{Defining Packages}): | |
1637 | ||
1638 | @example | |
1639 | @verbatiminclude package-hello.scm | |
1640 | @end example | |
1641 | ||
baacf042 | 1642 | Developers may find it useful to include such a @file{guix.scm} file |
f97c9175 | 1643 | in the root of their project source tree that can be used to test |
0d279400 DT |
1644 | development snapshots and create reproducible development environments |
1645 | (@pxref{Invoking guix environment}). | |
1646 | ||
6447738c MW |
1647 | @item --remove=@var{package} @dots{} |
1648 | @itemx -r @var{package} @dots{} | |
1649 | Remove the specified @var{package}s. | |
eeaf4427 | 1650 | |
6447738c | 1651 | As for @code{--install}, each @var{package} may specify a version number |
13ed095c LC |
1652 | and/or output name in addition to the package name. For instance, |
1653 | @code{-r glibc:debug} would remove the @code{debug} output of | |
1654 | @code{glibc}. | |
1655 | ||
6447738c MW |
1656 | @item --upgrade[=@var{regexp} @dots{}] |
1657 | @itemx -u [@var{regexp} @dots{}] | |
e32171ee | 1658 | @cindex upgrading packages |
6447738c MW |
1659 | Upgrade all the installed packages. If one or more @var{regexp}s are |
1660 | specified, upgrade only installed packages whose name matches a | |
d5f01e48 | 1661 | @var{regexp}. Also see the @code{--do-not-upgrade} option below. |
eeaf4427 | 1662 | |
f651b477 LC |
1663 | Note that this upgrades package to the latest version of packages found |
1664 | in the distribution currently installed. To update your distribution, | |
1665 | you should regularly run @command{guix pull} (@pxref{Invoking guix | |
1666 | pull}). | |
1667 | ||
d5f01e48 MW |
1668 | @item --do-not-upgrade[=@var{regexp} @dots{}] |
1669 | When used together with the @code{--upgrade} option, do @emph{not} | |
1670 | upgrade any packages whose name matches a @var{regexp}. For example, to | |
1671 | upgrade all packages in the current profile except those containing the | |
1672 | substring ``emacs'': | |
1673 | ||
1674 | @example | |
1675 | $ guix package --upgrade . --do-not-upgrade emacs | |
1676 | @end example | |
1677 | ||
99bd74d5 | 1678 | @item @anchor{profile-manifest}--manifest=@var{file} |
1b676447 | 1679 | @itemx -m @var{file} |
99bd74d5 LC |
1680 | @cindex profile declaration |
1681 | @cindex profile manifest | |
1682 | Create a new generation of the profile from the manifest object | |
1b676447 DT |
1683 | returned by the Scheme code in @var{file}. |
1684 | ||
99bd74d5 LC |
1685 | This allows you to @emph{declare} the profile's contents rather than |
1686 | constructing it through a sequence of @code{--install} and similar | |
1687 | commands. The advantage is that @var{file} can be put under version | |
1688 | control, copied to different machines to reproduce the same profile, and | |
1689 | so on. | |
1690 | ||
1691 | @c FIXME: Add reference to (guix profile) documentation when available. | |
1692 | @var{file} must return a @dfn{manifest} object, which is roughly a list | |
1693 | of packages: | |
1b676447 | 1694 | |
99bd74d5 | 1695 | @findex packages->manifest |
1b676447 | 1696 | @example |
99bd74d5 | 1697 | (use-package-modules guile emacs) |
1b676447 DT |
1698 | |
1699 | (packages->manifest | |
99bd74d5 LC |
1700 | (list emacs |
1701 | guile-2.0 | |
1b676447 | 1702 | ;; Use a specific package output. |
99bd74d5 | 1703 | (list guile-2.0 "debug"))) |
1b676447 DT |
1704 | @end example |
1705 | ||
6cd10593 LC |
1706 | @findex specification->package+output |
1707 | In this example we have to know which modules define the @code{emacs} | |
1708 | and @code{guile-2.0} variables to provide the right | |
1709 | @code{use-package-modules} line, which can be cumbersome. We can | |
1710 | instead provide regular package specifications and let | |
1711 | @code{specification->package-output} look up the corresponding package | |
1712 | objects, like this: | |
1713 | ||
1714 | @example | |
1715 | (packages->manifest | |
1716 | (map (compose list specification->package+output) | |
1717 | '("emacs" "guile@@2.0" "guile@@2.0:debug"))) | |
1718 | @end example | |
1719 | ||
24e262f0 | 1720 | @item --roll-back |
e32171ee JD |
1721 | @cindex rolling back |
1722 | @cindex undoing transactions | |
1723 | @cindex transactions, undoing | |
24e262f0 LC |
1724 | Roll back to the previous @dfn{generation} of the profile---i.e., undo |
1725 | the last transaction. | |
1726 | ||
1727 | When combined with options such as @code{--install}, roll back occurs | |
1728 | before any other actions. | |
1729 | ||
d9307267 | 1730 | When rolling back from the first generation that actually contains |
4b2bc804 | 1731 | installed packages, the profile is made to point to the @dfn{zeroth |
f97c9175 | 1732 | generation}, which contains no files apart from its own metadata. |
d9307267 | 1733 | |
f97c9175 AE |
1734 | After having rolled back, installing, removing, or upgrading packages |
1735 | overwrites previous future generations. Thus, the history of the | |
1736 | generations in a profile is always linear. | |
82fe08ed | 1737 | |
b3bb82f1 AK |
1738 | @item --switch-generation=@var{pattern} |
1739 | @itemx -S @var{pattern} | |
e32171ee | 1740 | @cindex generations |
b3bb82f1 AK |
1741 | Switch to a particular generation defined by @var{pattern}. |
1742 | ||
1743 | @var{pattern} may be either a generation number or a number prefixed | |
1744 | with ``+'' or ``-''. The latter means: move forward/backward by a | |
1745 | specified number of generations. For example, if you want to return to | |
1746 | the latest generation after @code{--roll-back}, use | |
1747 | @code{--switch-generation=+1}. | |
1748 | ||
1749 | The difference between @code{--roll-back} and | |
1750 | @code{--switch-generation=-1} is that @code{--switch-generation} will | |
1751 | not make a zeroth generation, so if a specified generation does not | |
1752 | exist, the current generation will not be changed. | |
1753 | ||
dbc31ab2 | 1754 | @item --search-paths[=@var{kind}] |
5924080d LC |
1755 | @cindex search paths |
1756 | Report environment variable definitions, in Bash syntax, that may be | |
1757 | needed in order to use the set of installed packages. These environment | |
1758 | variables are used to specify @dfn{search paths} for files used by some | |
1759 | of the installed packages. | |
1760 | ||
1761 | For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH} | |
1762 | environment variables to be defined so it can look for headers and | |
1763 | libraries in the user's profile (@pxref{Environment Variables,,, gcc, | |
1764 | Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C | |
1765 | library are installed in the profile, then @code{--search-paths} will | |
1766 | suggest setting these variables to @code{@var{profile}/include} and | |
1767 | @code{@var{profile}/lib}, respectively. | |
1768 | ||
dbc31ab2 LC |
1769 | The typical use case is to define these environment variables in the |
1770 | shell: | |
1771 | ||
1772 | @example | |
1773 | $ eval `guix package --search-paths` | |
1774 | @end example | |
1775 | ||
1776 | @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix}, | |
1777 | meaning that the returned environment variable definitions will either | |
1778 | be exact settings, or prefixes or suffixes of the current value of these | |
1779 | variables. When omitted, @var{kind} defaults to @code{exact}. | |
1780 | ||
fc2d2339 LC |
1781 | This option can also be used to compute the @emph{combined} search paths |
1782 | of several profiles. Consider this example: | |
1783 | ||
1784 | @example | |
1785 | $ guix package -p foo -i guile | |
1786 | $ guix package -p bar -i guile-json | |
1787 | $ guix package -p foo -p bar --search-paths | |
1788 | @end example | |
1789 | ||
1790 | The last command above reports about the @code{GUILE_LOAD_PATH} | |
1791 | variable, even though, taken individually, neither @file{foo} nor | |
1792 | @file{bar} would lead to that recommendation. | |
1793 | ||
1794 | ||
eeaf4427 LC |
1795 | @item --profile=@var{profile} |
1796 | @itemx -p @var{profile} | |
1797 | Use @var{profile} instead of the user's default profile. | |
1798 | ||
70915c1a | 1799 | @item --verbose |
f97c9175 AE |
1800 | Produce verbose output. In particular, emit the build log of the |
1801 | environment on the standard error port. | |
70915c1a | 1802 | |
eeaf4427 LC |
1803 | @item --bootstrap |
1804 | Use the bootstrap Guile to build the profile. This option is only | |
1805 | useful to distribution developers. | |
1806 | ||
1807 | @end table | |
1808 | ||
f97c9175 | 1809 | In addition to these actions, @command{guix package} supports the |
733b4130 LC |
1810 | following options to query the current state of a profile, or the |
1811 | availability of packages: | |
eeaf4427 | 1812 | |
733b4130 LC |
1813 | @table @option |
1814 | ||
acc08466 NK |
1815 | @item --search=@var{regexp} |
1816 | @itemx -s @var{regexp} | |
b110869d | 1817 | @cindex searching for packages |
5763ad92 | 1818 | List the available packages whose name, synopsis, or description matches |
f97c9175 | 1819 | @var{regexp}. Print all the metadata of matching packages in |
299112d3 LC |
1820 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, |
1821 | GNU recutils manual}). | |
acc08466 | 1822 | |
299112d3 LC |
1823 | This allows specific fields to be extracted using the @command{recsel} |
1824 | command, for instance: | |
1825 | ||
1826 | @example | |
e49951eb | 1827 | $ guix package -s malloc | recsel -p name,version |
299112d3 LC |
1828 | name: glibc |
1829 | version: 2.17 | |
1830 | ||
1831 | name: libgc | |
1832 | version: 7.2alpha6 | |
1833 | @end example | |
acc08466 | 1834 | |
a12d92f5 LC |
1835 | Similarly, to show the name of all the packages available under the |
1836 | terms of the GNU@tie{}LGPL version 3: | |
1837 | ||
1838 | @example | |
1839 | $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"' | |
1840 | name: elfutils | |
1841 | ||
1842 | name: gmp | |
1843 | @dots{} | |
1844 | @end example | |
1845 | ||
db5a9444 LC |
1846 | It is also possible to refine search results using several @code{-s} |
1847 | flags. For example, the following command returns a list of board | |
1848 | games: | |
1849 | ||
1850 | @example | |
1851 | $ guix package -s '\<board\>' -s game | recsel -p name | |
1852 | name: gnubg | |
1853 | @dots{} | |
1854 | @end example | |
1855 | ||
1856 | If we were to omit @code{-s game}, we would also get software packages | |
1857 | that deal with printed circuit boards; removing the angle brackets | |
1858 | around @code{board} would further add packages that have to do with | |
1859 | keyboards. | |
1860 | ||
b110869d LC |
1861 | And now for a more elaborate example. The following command searches |
1862 | for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby | |
1863 | libraries, and prints the name and synopsis of the matching packages: | |
1864 | ||
1865 | @example | |
1866 | $ guix package -s crypto -s library | \ | |
1867 | recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis | |
1868 | @end example | |
1869 | ||
1870 | @noindent | |
1871 | @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more | |
1872 | information on @dfn{selection expressions} for @code{recsel -e}. | |
1873 | ||
2aa6efb0 CR |
1874 | @item --show=@var{package} |
1875 | Show details about @var{package}, taken from the list of available packages, in | |
1876 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU | |
1877 | recutils manual}). | |
1878 | ||
1879 | @example | |
1880 | $ guix package --show=python | recsel -p name,version | |
1881 | name: python | |
1882 | version: 2.7.6 | |
1883 | ||
1884 | name: python | |
1885 | version: 3.3.5 | |
1886 | @end example | |
1887 | ||
1888 | You may also specify the full name of a package to only get details about a | |
1889 | specific version of it: | |
1890 | @example | |
ea206df4 | 1891 | $ guix package --show=python@@3.4 | recsel -p name,version |
2aa6efb0 | 1892 | name: python |
ea206df4 | 1893 | version: 3.4.3 |
2aa6efb0 CR |
1894 | @end example |
1895 | ||
1896 | ||
1897 | ||
733b4130 LC |
1898 | @item --list-installed[=@var{regexp}] |
1899 | @itemx -I [@var{regexp}] | |
bd9bde1c LC |
1900 | List the currently installed packages in the specified profile, with the |
1901 | most recently installed packages shown last. When @var{regexp} is | |
1902 | specified, list only installed packages whose name matches @var{regexp}. | |
733b4130 LC |
1903 | |
1904 | For each installed package, print the following items, separated by | |
1905 | tabs: the package name, its version string, the part of the package that | |
1906 | is installed (for instance, @code{out} for the default output, | |
1907 | @code{include} for its headers, etc.), and the path of this package in | |
1908 | the store. | |
1909 | ||
64fc89b6 LC |
1910 | @item --list-available[=@var{regexp}] |
1911 | @itemx -A [@var{regexp}] | |
5763ad92 | 1912 | List packages currently available in the distribution for this system |
a1ba8475 LC |
1913 | (@pxref{GNU Distribution}). When @var{regexp} is specified, list only |
1914 | installed packages whose name matches @var{regexp}. | |
64fc89b6 LC |
1915 | |
1916 | For each package, print the following items separated by tabs: its name, | |
6e721c4d LC |
1917 | its version string, the parts of the package (@pxref{Packages with |
1918 | Multiple Outputs}), and the source location of its definition. | |
64fc89b6 | 1919 | |
f566d765 LC |
1920 | @item --list-generations[=@var{pattern}] |
1921 | @itemx -l [@var{pattern}] | |
e32171ee | 1922 | @cindex generations |
f566d765 LC |
1923 | Return a list of generations along with their creation dates; for each |
1924 | generation, show the installed packages, with the most recently | |
4b2bc804 NK |
1925 | installed packages shown last. Note that the zeroth generation is never |
1926 | shown. | |
f566d765 LC |
1927 | |
1928 | For each installed package, print the following items, separated by | |
1929 | tabs: the name of a package, its version string, the part of the package | |
1930 | that is installed (@pxref{Packages with Multiple Outputs}), and the | |
1931 | location of this package in the store. | |
1932 | ||
1933 | When @var{pattern} is used, the command returns only matching | |
1934 | generations. Valid patterns include: | |
1935 | ||
1936 | @itemize | |
1937 | @item @emph{Integers and comma-separated integers}. Both patterns denote | |
1938 | generation numbers. For instance, @code{--list-generations=1} returns | |
1939 | the first one. | |
1940 | ||
1941 | And @code{--list-generations=1,8,2} outputs three generations in the | |
1942 | specified order. Neither spaces nor trailing commas are allowed. | |
1943 | ||
1944 | @item @emph{Ranges}. @code{--list-generations=2..9} prints the | |
1945 | specified generations and everything in between. Note that the start of | |
f97c9175 | 1946 | a range must be smaller than its end. |
f566d765 LC |
1947 | |
1948 | It is also possible to omit the endpoint. For example, | |
1949 | @code{--list-generations=2..}, returns all generations starting from the | |
1950 | second one. | |
1951 | ||
1952 | @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks, | |
1953 | or months by passing an integer along with the first letter of the | |
d7ddb257 LC |
1954 | duration. For example, @code{--list-generations=20d} lists generations |
1955 | that are up to 20 days old. | |
f566d765 LC |
1956 | @end itemize |
1957 | ||
b7884ca3 NK |
1958 | @item --delete-generations[=@var{pattern}] |
1959 | @itemx -d [@var{pattern}] | |
d7ddb257 LC |
1960 | When @var{pattern} is omitted, delete all generations except the current |
1961 | one. | |
b7884ca3 NK |
1962 | |
1963 | This command accepts the same patterns as @option{--list-generations}. | |
d7ddb257 LC |
1964 | When @var{pattern} is specified, delete the matching generations. When |
1965 | @var{pattern} specifies a duration, generations @emph{older} than the | |
1966 | specified duration match. For instance, @code{--delete-generations=1m} | |
1967 | deletes generations that are more than one month old. | |
1968 | ||
391bdd8f LC |
1969 | If the current generation matches, it is @emph{not} deleted. Also, the |
1970 | zeroth generation is never deleted. | |
b7884ca3 | 1971 | |
f97c9175 | 1972 | Note that deleting generations prevents rolling back to them. |
1bb9900a LC |
1973 | Consequently, this command must be used with care. |
1974 | ||
733b4130 | 1975 | @end table |
eeaf4427 | 1976 | |
70ee5642 | 1977 | Finally, since @command{guix package} may actually start build |
ccd7158d | 1978 | processes, it supports all the common build options (@pxref{Common Build |
f97c9175 | 1979 | Options}). It also supports package transformation options, such as |
b8638f03 LC |
1980 | @option{--with-source} (@pxref{Package Transformation Options}). |
1981 | However, note that package transformations are lost when upgrading; to | |
f97c9175 | 1982 | preserve transformations across upgrades, you should define your own |
b8638f03 LC |
1983 | package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH} |
1984 | (@pxref{Defining Packages}). | |
1985 | ||
70ee5642 | 1986 | |
c4202d60 LC |
1987 | @node Substitutes |
1988 | @section Substitutes | |
1989 | ||
1990 | @cindex substitutes | |
1991 | @cindex pre-built binaries | |
1992 | Guix supports transparent source/binary deployment, which means that it | |
1993 | can either build things locally, or download pre-built items from a | |
1994 | server. We call these pre-built items @dfn{substitutes}---they are | |
1995 | substitutes for local build results. In many cases, downloading a | |
1996 | substitute is much faster than building things locally. | |
1997 | ||
1998 | Substitutes can be anything resulting from a derivation build | |
1999 | (@pxref{Derivations}). Of course, in the common case, they are | |
2000 | pre-built package binaries, but source tarballs, for instance, which | |
2001 | also result from derivation builds, can be available as substitutes. | |
2002 | ||
2003 | The @code{hydra.gnu.org} server is a front-end to a build farm that | |
2004 | builds packages from the GNU distribution continuously for some | |
deb6276d | 2005 | architectures, and makes them available as substitutes. This is the |
f8a8e0fe LC |
2006 | default source of substitutes; it can be overridden by passing the |
2007 | @option{--substitute-urls} option either to @command{guix-daemon} | |
2008 | (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}}) | |
2009 | or to client tools such as @command{guix package} | |
2010 | (@pxref{client-substitute-urls,, client @option{--substitute-urls} | |
2011 | option}). | |
c4202d60 | 2012 | |
1dbe3a8d | 2013 | Substitute URLs can be either HTTP or HTTPS. |
9b7bd1b1 LC |
2014 | HTTPS is recommended because communications are encrypted; conversely, |
2015 | using HTTP makes all communications visible to an eavesdropper, who | |
2016 | could use the information gathered to determine, for instance, whether | |
2017 | your system has unpatched security vulnerabilities. | |
2018 | ||
c4202d60 LC |
2019 | @cindex security |
2020 | @cindex digital signatures | |
e32171ee | 2021 | @cindex substitutes, authorization thereof |
df061d07 LC |
2022 | To allow Guix to download substitutes from @code{hydra.gnu.org} or a |
2023 | mirror thereof, you | |
c4202d60 LC |
2024 | must add its public key to the access control list (ACL) of archive |
2025 | imports, using the @command{guix archive} command (@pxref{Invoking guix | |
2026 | archive}). Doing so implies that you trust @code{hydra.gnu.org} to not | |
2027 | be compromised and to serve genuine substitutes. | |
2028 | ||
2029 | This public key is installed along with Guix, in | |
2030 | @code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is | |
2031 | the installation prefix of Guix. If you installed Guix from source, | |
2032 | make sure you checked the GPG signature of | |
2033 | @file{guix-@value{VERSION}.tar.gz}, which contains this public key file. | |
2034 | Then, you can run something like this: | |
2035 | ||
2036 | @example | |
2037 | # guix archive --authorize < hydra.gnu.org.pub | |
2038 | @end example | |
2039 | ||
2040 | Once this is in place, the output of a command like @code{guix build} | |
2041 | should change from something like: | |
2042 | ||
2043 | @example | |
2044 | $ guix build emacs --dry-run | |
2045 | The following derivations would be built: | |
2046 | /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv | |
2047 | /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv | |
2048 | /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv | |
2049 | /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv | |
2050 | @dots{} | |
2051 | @end example | |
2052 | ||
2053 | @noindent | |
2054 | to something like: | |
2055 | ||
2056 | @example | |
2057 | $ guix build emacs --dry-run | |
2058 | The following files would be downloaded: | |
2059 | /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3 | |
2060 | /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d | |
2061 | /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16 | |
2062 | /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7 | |
2063 | @dots{} | |
2064 | @end example | |
2065 | ||
2066 | @noindent | |
2067 | This indicates that substitutes from @code{hydra.gnu.org} are usable and | |
2068 | will be downloaded, when possible, for future builds. | |
2069 | ||
2070 | Guix ignores substitutes that are not signed, or that are not signed by | |
ef27aa9c | 2071 | one of the keys listed in the ACL. It also detects and raises an error |
c4202d60 LC |
2072 | when attempting to use a substitute that has been tampered with. |
2073 | ||
e0c941fe | 2074 | @vindex http_proxy |
9b7bd1b1 LC |
2075 | Substitutes are downloaded over HTTP or HTTPS. |
2076 | The @code{http_proxy} environment | |
e0c941fe LC |
2077 | variable can be set in the environment of @command{guix-daemon} and is |
2078 | honored for downloads of substitutes. Note that the value of | |
2079 | @code{http_proxy} in the environment where @command{guix build}, | |
2080 | @command{guix package}, and other client commands are run has | |
2081 | @emph{absolutely no effect}. | |
2082 | ||
9b7bd1b1 LC |
2083 | When using HTTPS, the server's X.509 certificate is @emph{not} validated |
2084 | (in other words, the server is not authenticated), contrary to what | |
2085 | HTTPS clients such as Web browsers usually do. This is because Guix | |
2086 | authenticates substitute information itself, as explained above, which | |
2087 | is what we care about (whereas X.509 certificates are about | |
2088 | authenticating bindings between domain names and public keys.) | |
2089 | ||
c4202d60 LC |
2090 | The substitute mechanism can be disabled globally by running |
2091 | @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking | |
2092 | guix-daemon}). It can also be disabled temporarily by passing the | |
2093 | @code{--no-substitutes} option to @command{guix package}, @command{guix | |
2094 | build}, and other command-line tools. | |
2095 | ||
2096 | ||
9b7bd1b1 LC |
2097 | @unnumberedsubsec On Trusting Binaries |
2098 | ||
c4202d60 LC |
2099 | Today, each individual's control over their own computing is at the |
2100 | mercy of institutions, corporations, and groups with enough power and | |
2101 | determination to subvert the computing infrastructure and exploit its | |
2102 | weaknesses. While using @code{hydra.gnu.org} substitutes can be | |
2103 | convenient, we encourage users to also build on their own, or even run | |
2104 | their own build farm, such that @code{hydra.gnu.org} is less of an | |
8ce229fc LC |
2105 | interesting target. One way to help is by publishing the software you |
2106 | build using @command{guix publish} so that others have one more choice | |
2107 | of server to download substitutes from (@pxref{Invoking guix publish}). | |
c4202d60 LC |
2108 | |
2109 | Guix has the foundations to maximize build reproducibility | |
2110 | (@pxref{Features}). In most cases, independent builds of a given | |
2111 | package or derivation should yield bit-identical results. Thus, through | |
2112 | a diverse set of independent package builds, we can strengthen the | |
d23c20f1 LC |
2113 | integrity of our systems. The @command{guix challenge} command aims to |
2114 | help users assess substitute servers, and to assist developers in | |
2115 | finding out about non-deterministic package builds (@pxref{Invoking guix | |
a8d65643 LC |
2116 | challenge}). Similarly, the @option{--check} option of @command{guix |
2117 | build} allows users to check whether previously-installed substitutes | |
2118 | are genuine by rebuilding them locally (@pxref{build-check, | |
2119 | @command{guix build --check}}). | |
c4202d60 LC |
2120 | |
2121 | In the future, we want Guix to have support to publish and retrieve | |
2122 | binaries to/from other users, in a peer-to-peer fashion. If you would | |
2123 | like to discuss this project, join us on @email{guix-devel@@gnu.org}. | |
2124 | ||
2125 | ||
6e721c4d LC |
2126 | @node Packages with Multiple Outputs |
2127 | @section Packages with Multiple Outputs | |
2128 | ||
2129 | @cindex multiple-output packages | |
2130 | @cindex package outputs | |
e32171ee | 2131 | @cindex outputs |
6e721c4d LC |
2132 | |
2133 | Often, packages defined in Guix have a single @dfn{output}---i.e., the | |
f97c9175 | 2134 | source package leads to exactly one directory in the store. When running |
6e721c4d LC |
2135 | @command{guix package -i glibc}, one installs the default output of the |
2136 | GNU libc package; the default output is called @code{out}, but its name | |
2137 | can be omitted as shown in this command. In this particular case, the | |
2138 | default output of @code{glibc} contains all the C header files, shared | |
2139 | libraries, static libraries, Info documentation, and other supporting | |
2140 | files. | |
2141 | ||
2142 | Sometimes it is more appropriate to separate the various types of files | |
2143 | produced from a single source package into separate outputs. For | |
2144 | instance, the GLib C library (used by GTK+ and related packages) | |
2145 | installs more than 20 MiB of reference documentation as HTML pages. | |
2146 | To save space for users who do not need it, the documentation goes to a | |
2147 | separate output, called @code{doc}. To install the main GLib output, | |
2148 | which contains everything but the documentation, one would run: | |
2149 | ||
2150 | @example | |
2151 | guix package -i glib | |
2152 | @end example | |
2153 | ||
e32171ee | 2154 | @cindex documentation |
6e721c4d LC |
2155 | The command to install its documentation is: |
2156 | ||
2157 | @example | |
2158 | guix package -i glib:doc | |
2159 | @end example | |
2160 | ||
2161 | Some packages install programs with different ``dependency footprints''. | |
f97c9175 | 2162 | For instance, the WordNet package installs both command-line tools and |
6e721c4d LC |
2163 | graphical user interfaces (GUIs). The former depend solely on the C |
2164 | library, whereas the latter depend on Tcl/Tk and the underlying X | |
2165 | libraries. In this case, we leave the command-line tools in the default | |
2166 | output, whereas the GUIs are in a separate output. This allows users | |
fcc58db6 LC |
2167 | who do not need the GUIs to save space. The @command{guix size} command |
2168 | can help find out about such situations (@pxref{Invoking guix size}). | |
88856916 | 2169 | @command{guix graph} can also be helpful (@pxref{Invoking guix graph}). |
6e721c4d LC |
2170 | |
2171 | There are several such multiple-output packages in the GNU distribution. | |
91ef73d4 LC |
2172 | Other conventional output names include @code{lib} for libraries and |
2173 | possibly header files, @code{bin} for stand-alone programs, and | |
2174 | @code{debug} for debugging information (@pxref{Installing Debugging | |
2175 | Files}). The outputs of a packages are listed in the third column of | |
2176 | the output of @command{guix package --list-available} (@pxref{Invoking | |
2177 | guix package}). | |
6e721c4d | 2178 | |
eeaf4427 | 2179 | |
e49951eb MW |
2180 | @node Invoking guix gc |
2181 | @section Invoking @command{guix gc} | |
fe8ff028 LC |
2182 | |
2183 | @cindex garbage collector | |
e32171ee | 2184 | @cindex disk space |
f97c9175 | 2185 | Packages that are installed, but not used, may be @dfn{garbage-collected}. |
e49951eb | 2186 | The @command{guix gc} command allows users to explicitly run the garbage |
c22eb992 LC |
2187 | collector to reclaim space from the @file{/gnu/store} directory. It is |
2188 | the @emph{only} way to remove files from @file{/gnu/store}---removing | |
2189 | files or directories manually may break it beyond repair! | |
fe8ff028 LC |
2190 | |
2191 | The garbage collector has a set of known @dfn{roots}: any file under | |
834129e0 | 2192 | @file{/gnu/store} reachable from a root is considered @dfn{live} and |
fe8ff028 LC |
2193 | cannot be deleted; any other file is considered @dfn{dead} and may be |
2194 | deleted. The set of garbage collector roots includes default user | |
e49951eb MW |
2195 | profiles, and may be augmented with @command{guix build --root}, for |
2196 | example (@pxref{Invoking guix build}). | |
fe8ff028 | 2197 | |
1bb9900a LC |
2198 | Prior to running @code{guix gc --collect-garbage} to make space, it is |
2199 | often useful to remove old generations from user profiles; that way, old | |
2200 | package builds referenced by those generations can be reclaimed. This | |
2201 | is achieved by running @code{guix package --delete-generations} | |
2202 | (@pxref{Invoking guix package}). | |
2203 | ||
e49951eb | 2204 | The @command{guix gc} command has three modes of operation: it can be |
fe8ff028 | 2205 | used to garbage-collect any dead files (the default), to delete specific |
7770aafc LC |
2206 | files (the @code{--delete} option), to print garbage-collector |
2207 | information, or for more advanced queries. The garbage collection | |
2208 | options are as follows: | |
fe8ff028 LC |
2209 | |
2210 | @table @code | |
2211 | @item --collect-garbage[=@var{min}] | |
2212 | @itemx -C [@var{min}] | |
834129e0 | 2213 | Collect garbage---i.e., unreachable @file{/gnu/store} files and |
fe8ff028 LC |
2214 | sub-directories. This is the default operation when no option is |
2215 | specified. | |
2216 | ||
2217 | When @var{min} is given, stop once @var{min} bytes have been collected. | |
2218 | @var{min} may be a number of bytes, or it may include a unit as a | |
4a44d7bb LC |
2219 | suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes |
2220 | (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}). | |
fe8ff028 LC |
2221 | |
2222 | When @var{min} is omitted, collect all the garbage. | |
2223 | ||
0054e470 LC |
2224 | @item --free-space=@var{free} |
2225 | @itemx -F @var{free} | |
2226 | Collect garbage until @var{free} space is available under | |
2227 | @file{/gnu/store}, if possible; @var{free} denotes storage space, such | |
2228 | as @code{500MiB}, as described above. | |
2229 | ||
2230 | When @var{free} or more is already available in @file{/gnu/store}, do | |
2231 | nothing and exit immediately. | |
2232 | ||
fe8ff028 LC |
2233 | @item --delete |
2234 | @itemx -d | |
2235 | Attempt to delete all the store files and directories specified as | |
2236 | arguments. This fails if some of the files are not in the store, or if | |
2237 | they are still live. | |
2238 | ||
30d9aa54 LC |
2239 | @item --list-failures |
2240 | List store items corresponding to cached build failures. | |
2241 | ||
2242 | This prints nothing unless the daemon was started with | |
2243 | @option{--cache-failures} (@pxref{Invoking guix-daemon, | |
2244 | @option{--cache-failures}}). | |
2245 | ||
2246 | @item --clear-failures | |
2247 | Remove the specified store items from the failed-build cache. | |
2248 | ||
2249 | Again, this option only makes sense when the daemon is started with | |
2250 | @option{--cache-failures}. Otherwise, it does nothing. | |
2251 | ||
fe8ff028 LC |
2252 | @item --list-dead |
2253 | Show the list of dead files and directories still present in the | |
2254 | store---i.e., files and directories no longer reachable from any root. | |
2255 | ||
2256 | @item --list-live | |
2257 | Show the list of live store files and directories. | |
ba8b732d LC |
2258 | |
2259 | @end table | |
2260 | ||
2261 | In addition, the references among existing store files can be queried: | |
2262 | ||
2263 | @table @code | |
2264 | ||
2265 | @item --references | |
2266 | @itemx --referrers | |
e32171ee | 2267 | @cindex package dependencies |
ba8b732d LC |
2268 | List the references (respectively, the referrers) of store files given |
2269 | as arguments. | |
2270 | ||
8e59fdd5 LC |
2271 | @item --requisites |
2272 | @itemx -R | |
fcc58db6 | 2273 | @cindex closure |
8e59fdd5 LC |
2274 | List the requisites of the store files passed as arguments. Requisites |
2275 | include the store files themselves, their references, and the references | |
2276 | of these, recursively. In other words, the returned list is the | |
2277 | @dfn{transitive closure} of the store files. | |
2278 | ||
f97c9175 AE |
2279 | @xref{Invoking guix size}, for a tool to profile the size of the closure |
2280 | of an element. @xref{Invoking guix graph}, for a tool to visualize | |
88856916 | 2281 | the graph of references. |
fcc58db6 | 2282 | |
fe8ff028 LC |
2283 | @end table |
2284 | ||
7770aafc LC |
2285 | Lastly, the following options allow you to check the integrity of the |
2286 | store and to control disk usage. | |
2287 | ||
2288 | @table @option | |
2289 | ||
2290 | @item --verify[=@var{options}] | |
2291 | @cindex integrity, of the store | |
2292 | @cindex integrity checking | |
2293 | Verify the integrity of the store. | |
2294 | ||
2295 | By default, make sure that all the store items marked as valid in the | |
f97c9175 | 2296 | database of the daemon actually exist in @file{/gnu/store}. |
7770aafc | 2297 | |
f97c9175 | 2298 | When provided, @var{options} must be a comma-separated list containing one |
7770aafc LC |
2299 | or more of @code{contents} and @code{repair}. |
2300 | ||
7414de0a | 2301 | When passing @option{--verify=contents}, the daemon computes the |
f97c9175 | 2302 | content hash of each store item and compares it against its hash in the |
7770aafc LC |
2303 | database. Hash mismatches are reported as data corruptions. Because it |
2304 | traverses @emph{all the files in the store}, this command can take a | |
2305 | long time, especially on systems with a slow disk drive. | |
2306 | ||
2307 | @cindex repairing the store | |
6da5bb7b | 2308 | @cindex corruption, recovering from |
7770aafc LC |
2309 | Using @option{--verify=repair} or @option{--verify=contents,repair} |
2310 | causes the daemon to try to repair corrupt store items by fetching | |
2311 | substitutes for them (@pxref{Substitutes}). Because repairing is not | |
2312 | atomic, and thus potentially dangerous, it is available only to the | |
6da5bb7b LC |
2313 | system administrator. A lightweight alternative, when you know exactly |
2314 | which items in the store are corrupt, is @command{guix build --repair} | |
2315 | (@pxref{Invoking guix build}). | |
7770aafc LC |
2316 | |
2317 | @item --optimize | |
2318 | @cindex deduplication | |
2319 | Optimize the store by hard-linking identical files---this is | |
2320 | @dfn{deduplication}. | |
2321 | ||
2322 | The daemon performs deduplication after each successful build or archive | |
2323 | import, unless it was started with @code{--disable-deduplication} | |
2324 | (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus, | |
2325 | this option is primarily useful when the daemon was running with | |
2326 | @code{--disable-deduplication}. | |
2327 | ||
2328 | @end table | |
eeaf4427 | 2329 | |
f651b477 LC |
2330 | @node Invoking guix pull |
2331 | @section Invoking @command{guix pull} | |
2332 | ||
e32171ee | 2333 | @cindex upgrading Guix |
7fcf2a0b | 2334 | @cindex updating Guix |
e32171ee JD |
2335 | @cindex @command{guix pull} |
2336 | @cindex pull | |
f651b477 LC |
2337 | Packages are installed or upgraded to the latest version available in |
2338 | the distribution currently available on your local machine. To update | |
2339 | that distribution, along with the Guix tools, you must run @command{guix | |
2340 | pull}: the command downloads the latest Guix source code and package | |
2341 | descriptions, and deploys it. | |
2342 | ||
2343 | On completion, @command{guix package} will use packages and package | |
2344 | versions from this just-retrieved copy of Guix. Not only that, but all | |
2345 | the Guix commands and Scheme modules will also be taken from that latest | |
2346 | version. New @command{guix} sub-commands added by the update also | |
cb05108a LC |
2347 | become available. |
2348 | ||
2349 | Any user can update their Guix copy using @command{guix pull}, and the | |
2350 | effect is limited to the user who run @command{guix pull}. For | |
2351 | instance, when user @code{root} runs @command{guix pull}, this has no | |
2352 | effect on the version of Guix that user @code{alice} sees, and vice | |
2353 | versa@footnote{Under the hood, @command{guix pull} updates the | |
2354 | @file{~/.config/guix/latest} symbolic link to point to the latest Guix, | |
5e2017ed CM |
2355 | and the @command{guix} command loads code from there. Currently, the |
2356 | only way to roll back an invocation of @command{guix pull} is to | |
2357 | manually update this symlink to point to the previous Guix.}. | |
f651b477 LC |
2358 | |
2359 | The @command{guix pull} command is usually invoked with no arguments, | |
2360 | but it supports the following options: | |
2361 | ||
2362 | @table @code | |
2363 | @item --verbose | |
2364 | Produce verbose output, writing build logs to the standard error output. | |
2365 | ||
ab5d72ad LC |
2366 | @item --url=@var{url} |
2367 | Download the source tarball of Guix from @var{url}. | |
2368 | ||
2369 | By default, the tarball is taken from its canonical address at | |
2370 | @code{gnu.org}, for the stable branch of Guix. | |
2371 | ||
8a9cffb2 LF |
2372 | With some Git servers, this can be used to deploy any version of Guix. |
2373 | For example, to download and deploy version 0.12.0 of Guix from the | |
2374 | canonical Git repo: | |
2375 | ||
2376 | @example | |
2377 | guix pull --url=http://git.savannah.gnu.org/cgit/guix.git/snapshot/v0.12.0.tar.gz | |
2378 | @end example | |
2379 | ||
2380 | It can also be used to deploy arbitrary Git revisions: | |
2381 | ||
2382 | @example | |
2383 | guix pull --url=http://git.savannah.gnu.org/cgit/guix.git/snapshot/74d862e8a.tar.gz | |
2384 | @end example | |
2385 | ||
f651b477 LC |
2386 | @item --bootstrap |
2387 | Use the bootstrap Guile to build the latest Guix. This option is only | |
2388 | useful to Guix developers. | |
2389 | @end table | |
2390 | ||
760c60d6 | 2391 | |
239c2266 LC |
2392 | @node Invoking guix pack |
2393 | @section Invoking @command{guix pack} | |
2394 | ||
2395 | Occasionally you want to pass software to people who are not (yet!) | |
2396 | lucky enough to be using Guix. You'd tell them to run @command{guix | |
2397 | package -i @var{something}}, but that's not possible in this case. This | |
2398 | is where @command{guix pack} comes in. | |
2399 | ||
2400 | @cindex pack | |
2401 | @cindex bundle | |
2402 | @cindex application bundle | |
2403 | @cindex software bundle | |
2404 | The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or | |
2405 | @dfn{software bundle}: it creates a tarball or some other archive | |
2406 | containing the binaries of the software you're interested in, and all | |
2407 | its dependencies. The resulting archive can be used on any machine that | |
2408 | does not have Guix, and people can run the exact same binaries as those | |
107b8da6 LC |
2409 | you have with Guix. The pack itself is created in a bit-reproducible |
2410 | fashion, so anyone can verify that it really contains the build results | |
2411 | that you pretend to be shipping. | |
239c2266 LC |
2412 | |
2413 | For example, to create a bundle containing Guile, Emacs, Geiser, and all | |
2414 | their dependencies, you can run: | |
2415 | ||
2416 | @example | |
2417 | $ guix pack guile emacs geiser | |
2418 | @dots{} | |
2419 | /gnu/store/@dots{}-pack.tar.gz | |
2420 | @end example | |
2421 | ||
2422 | The result here is a tarball containing a @file{/gnu/store} directory | |
2423 | with all the relevant packages. The resulting tarball contains a | |
2424 | @dfn{profile} with the three packages of interest; the profile is the | |
2425 | same as would be created by @command{guix package -i}. It is this | |
2426 | mechanism that is used to create Guix's own standalone binary tarball | |
2427 | (@pxref{Binary Installation}). | |
2428 | ||
5895ec8a LC |
2429 | Users of this pack would have to run |
2430 | @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may | |
2431 | find inconvenient. To work around it, you can create, say, a | |
2432 | @file{/opt/gnu/bin} symlink to the profile: | |
2433 | ||
2434 | @example | |
2435 | guix pack -S /opt/gnu/bin=bin guile emacs geiser | |
2436 | @end example | |
2437 | ||
2438 | @noindent | |
2439 | That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy. | |
2440 | ||
708b54a9 LC |
2441 | Alternatively, you can produce a pack in the Docker image format using |
2442 | the following command: | |
b1edfbc3 LC |
2443 | |
2444 | @example | |
2445 | guix pack -f docker guile emacs geiser | |
2446 | @end example | |
2447 | ||
2448 | @noindent | |
2449 | The result is a tarball that can be passed to the @command{docker load} | |
2450 | command. See the | |
2451 | @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker | |
2452 | documentation} for more information. | |
2453 | ||
239c2266 LC |
2454 | Several command-line options allow you to customize your pack: |
2455 | ||
2456 | @table @code | |
708b54a9 LC |
2457 | @item --format=@var{format} |
2458 | @itemx -f @var{format} | |
2459 | Produce a pack in the given @var{format}. | |
2460 | ||
2461 | The available formats are: | |
2462 | ||
2463 | @table @code | |
2464 | @item tarball | |
2465 | This is the default format. It produces a tarball containing all the | |
2466 | specifies binaries and symlinks. | |
2467 | ||
2468 | @item docker | |
2469 | This produces a tarball that follows the | |
2470 | @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md, | |
2471 | Docker Image Specification}. | |
2472 | @end table | |
2473 | ||
239c2266 LC |
2474 | @item --system=@var{system} |
2475 | @itemx -s @var{system} | |
2476 | Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of | |
2477 | the system type of the build host. | |
2478 | ||
5461115e LC |
2479 | @item --target=@var{triplet} |
2480 | @cindex cross-compilation | |
2481 | Cross-build for @var{triplet}, which must be a valid GNU triplet, such | |
2482 | as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU | |
2483 | configuration triplets,, autoconf, Autoconf}). | |
2484 | ||
239c2266 LC |
2485 | @item --compression=@var{tool} |
2486 | @itemx -C @var{tool} | |
2487 | Compress the resulting tarball using @var{tool}---one of @code{gzip}, | |
2488 | @code{bzip2}, @code{xz}, or @code{lzip}. | |
6b63c43e | 2489 | |
5895ec8a LC |
2490 | @item --symlink=@var{spec} |
2491 | @itemx -S @var{spec} | |
2492 | Add the symlinks specified by @var{spec} to the pack. This option can | |
2493 | appear several times. | |
2494 | ||
2495 | @var{spec} has the form @code{@var{source}=@var{target}}, where | |
2496 | @var{source} is the symlink that will be created and @var{target} is the | |
2497 | symlink target. | |
2498 | ||
2499 | For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin} | |
2500 | symlink pointing to the @file{bin} sub-directory of the profile. | |
2501 | ||
6b63c43e LC |
2502 | @item --localstatedir |
2503 | Include the ``local state directory'', @file{/var/guix}, in the | |
2504 | resulting pack. | |
2505 | ||
2506 | @file{/var/guix} contains the store database (@pxref{The Store}) as well | |
2507 | as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in | |
2508 | the pack means that the store is ``complete'' and manageable by Guix; | |
2509 | not providing it pack means that the store is ``dead'': items cannot be | |
2510 | added to it or removed from it after extraction of the pack. | |
2511 | ||
2512 | One use case for this is the Guix self-contained binary tarball | |
2513 | (@pxref{Binary Installation}). | |
239c2266 LC |
2514 | @end table |
2515 | ||
2516 | In addition, @command{guix pack} supports all the common build options | |
2517 | (@pxref{Common Build Options}) and all the package transformation | |
2518 | options (@pxref{Package Transformation Options}). | |
2519 | ||
2520 | ||
760c60d6 LC |
2521 | @node Invoking guix archive |
2522 | @section Invoking @command{guix archive} | |
2523 | ||
e32171ee JD |
2524 | @cindex @command{guix archive} |
2525 | @cindex archive | |
760c60d6 LC |
2526 | The @command{guix archive} command allows users to @dfn{export} files |
2527 | from the store into a single archive, and to later @dfn{import} them. | |
2528 | In particular, it allows store files to be transferred from one machine | |
4d4c4816 AE |
2529 | to the store on another machine. |
2530 | ||
e32171ee | 2531 | @cindex exporting store items |
4d4c4816 AE |
2532 | To export store files as an archive to standard output, run: |
2533 | ||
2534 | @example | |
2535 | guix archive --export @var{options} @var{specifications}... | |
2536 | @end example | |
2537 | ||
2538 | @var{specifications} may be either store file names or package | |
2539 | specifications, as for @command{guix package} (@pxref{Invoking guix | |
2540 | package}). For instance, the following command creates an archive | |
2541 | containing the @code{gui} output of the @code{git} package and the main | |
2542 | output of @code{emacs}: | |
2543 | ||
2544 | @example | |
2545 | guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar | |
2546 | @end example | |
2547 | ||
2548 | If the specified packages are not built yet, @command{guix archive} | |
2549 | automatically builds them. The build process may be controlled with the | |
2550 | common build options (@pxref{Common Build Options}). | |
2551 | ||
2552 | To transfer the @code{emacs} package to a machine connected over SSH, | |
2553 | one would run: | |
760c60d6 LC |
2554 | |
2555 | @example | |
56607088 | 2556 | guix archive --export -r emacs | ssh the-machine guix archive --import |
760c60d6 LC |
2557 | @end example |
2558 | ||
87236aed | 2559 | @noindent |
56607088 LC |
2560 | Similarly, a complete user profile may be transferred from one machine |
2561 | to another like this: | |
2562 | ||
2563 | @example | |
2564 | guix archive --export -r $(readlink -f ~/.guix-profile) | \ | |
2565 | ssh the-machine guix-archive --import | |
2566 | @end example | |
2567 | ||
2568 | @noindent | |
2569 | However, note that, in both examples, all of @code{emacs} and the | |
2570 | profile as well as all of their dependencies are transferred (due to | |
f97c9175 AE |
2571 | @code{-r}), regardless of what is already available in the store on the |
2572 | target machine. The @code{--missing} option can help figure out which | |
f11c444d LC |
2573 | items are missing from the target store. The @command{guix copy} |
2574 | command simplifies and optimizes this whole process, so this is probably | |
2575 | what you should use in this case (@pxref{Invoking guix copy}). | |
87236aed | 2576 | |
5597b3ae LC |
2577 | @cindex nar, archive format |
2578 | @cindex normalized archive (nar) | |
b1edfbc3 | 2579 | Archives are stored in the ``normalized archive'' or ``nar'' format, which is |
5597b3ae | 2580 | comparable in spirit to `tar', but with differences |
0dbd88db | 2581 | that make it more appropriate for our purposes. First, rather than |
5597b3ae | 2582 | recording all Unix metadata for each file, the nar format only mentions |
0dbd88db LC |
2583 | the file type (regular, directory, or symbolic link); Unix permissions |
2584 | and owner/group are dismissed. Second, the order in which directory | |
2585 | entries are stored always follows the order of file names according to | |
2586 | the C locale collation order. This makes archive production fully | |
2587 | deterministic. | |
2588 | ||
2589 | When exporting, the daemon digitally signs the contents of the archive, | |
2590 | and that digital signature is appended. When importing, the daemon | |
2591 | verifies the signature and rejects the import in case of an invalid | |
2592 | signature or if the signing key is not authorized. | |
760c60d6 LC |
2593 | @c FIXME: Add xref to daemon doc about signatures. |
2594 | ||
2595 | The main options are: | |
2596 | ||
2597 | @table @code | |
2598 | @item --export | |
2599 | Export the specified store files or packages (see below.) Write the | |
2600 | resulting archive to the standard output. | |
2601 | ||
56607088 LC |
2602 | Dependencies are @emph{not} included in the output, unless |
2603 | @code{--recursive} is passed. | |
2604 | ||
2605 | @item -r | |
2606 | @itemx --recursive | |
2607 | When combined with @code{--export}, this instructs @command{guix | |
2608 | archive} to include dependencies of the given items in the archive. | |
2609 | Thus, the resulting archive is self-contained: it contains the closure | |
2610 | of the exported store items. | |
2611 | ||
760c60d6 LC |
2612 | @item --import |
2613 | Read an archive from the standard input, and import the files listed | |
2614 | therein into the store. Abort if the archive has an invalid digital | |
f82cc5fd LC |
2615 | signature, or if it is signed by a public key not among the authorized |
2616 | keys (see @code{--authorize} below.) | |
554f26ec | 2617 | |
87236aed LC |
2618 | @item --missing |
2619 | Read a list of store file names from the standard input, one per line, | |
2620 | and write on the standard output the subset of these files missing from | |
2621 | the store. | |
2622 | ||
554f26ec | 2623 | @item --generate-key[=@var{parameters}] |
f82cc5fd | 2624 | @cindex signing, archives |
f97c9175 | 2625 | Generate a new key pair for the daemon. This is a prerequisite before |
554f26ec LC |
2626 | archives can be exported with @code{--export}. Note that this operation |
2627 | usually takes time, because it needs to gather enough entropy to | |
2628 | generate the key pair. | |
2629 | ||
2630 | The generated key pair is typically stored under @file{/etc/guix}, in | |
2631 | @file{signing-key.pub} (public key) and @file{signing-key.sec} (private | |
867d8473 LC |
2632 | key, which must be kept secret.) When @var{parameters} is omitted, |
2633 | an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt | |
2634 | versions before 1.6.0, it is a 4096-bit RSA key. | |
f97c9175 | 2635 | Alternatively, @var{parameters} can specify |
554f26ec LC |
2636 | @code{genkey} parameters suitable for Libgcrypt (@pxref{General |
2637 | public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The | |
2638 | Libgcrypt Reference Manual}). | |
f82cc5fd LC |
2639 | |
2640 | @item --authorize | |
2641 | @cindex authorizing, archives | |
2642 | Authorize imports signed by the public key passed on standard input. | |
2643 | The public key must be in ``s-expression advanced format''---i.e., the | |
2644 | same format as the @file{signing-key.pub} file. | |
2645 | ||
2646 | The list of authorized keys is kept in the human-editable file | |
2647 | @file{/etc/guix/acl}. The file contains | |
2648 | @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format | |
2649 | s-expressions''} and is structured as an access-control list in the | |
2650 | @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure | |
2651 | (SPKI)}. | |
c6f8e9dd LC |
2652 | |
2653 | @item --extract=@var{directory} | |
2654 | @itemx -x @var{directory} | |
2655 | Read a single-item archive as served by substitute servers | |
2656 | (@pxref{Substitutes}) and extract it to @var{directory}. This is a | |
2657 | low-level operation needed in only very narrow use cases; see below. | |
2658 | ||
2659 | For example, the following command extracts the substitute for Emacs | |
2660 | served by @code{hydra.gnu.org} to @file{/tmp/emacs}: | |
2661 | ||
2662 | @example | |
2663 | $ wget -O - \ | |
df061d07 | 2664 | https://hydra.gnu.org/nar/@dots{}-emacs-24.5 \ |
c6f8e9dd LC |
2665 | | bunzip2 | guix archive -x /tmp/emacs |
2666 | @end example | |
2667 | ||
2668 | Single-item archives are different from multiple-item archives produced | |
2669 | by @command{guix archive --export}; they contain a single store item, | |
2670 | and they do @emph{not} embed a signature. Thus this operation does | |
2671 | @emph{no} signature verification and its output should be considered | |
2672 | unsafe. | |
2673 | ||
2674 | The primary purpose of this operation is to facilitate inspection of | |
2675 | archive contents coming from possibly untrusted substitute servers. | |
2676 | ||
760c60d6 LC |
2677 | @end table |
2678 | ||
568717fd LC |
2679 | @c ********************************************************************* |
2680 | @node Programming Interface | |
2681 | @chapter Programming Interface | |
2682 | ||
3dc1970d LC |
2683 | GNU Guix provides several Scheme programming interfaces (APIs) to |
2684 | define, build, and query packages. The first interface allows users to | |
2685 | write high-level package definitions. These definitions refer to | |
2686 | familiar packaging concepts, such as the name and version of a package, | |
2687 | its build system, and its dependencies. These definitions can then be | |
2688 | turned into concrete build actions. | |
2689 | ||
ba55b1cb | 2690 | Build actions are performed by the Guix daemon, on behalf of users. In a |
3dc1970d | 2691 | standard setup, the daemon has write access to the store---the |
834129e0 | 2692 | @file{/gnu/store} directory---whereas users do not. The recommended |
3dc1970d LC |
2693 | setup also has the daemon perform builds in chroots, under a specific |
2694 | build users, to minimize interference with the rest of the system. | |
2695 | ||
2696 | @cindex derivation | |
2697 | Lower-level APIs are available to interact with the daemon and the | |
2698 | store. To instruct the daemon to perform a build action, users actually | |
2699 | provide it with a @dfn{derivation}. A derivation is a low-level | |
2700 | representation of the build actions to be taken, and the environment in | |
2701 | which they should occur---derivations are to package definitions what | |
49ad317a LC |
2702 | assembly is to C programs. The term ``derivation'' comes from the fact |
2703 | that build results @emph{derive} from them. | |
3dc1970d LC |
2704 | |
2705 | This chapter describes all these APIs in turn, starting from high-level | |
2706 | package definitions. | |
2707 | ||
568717fd | 2708 | @menu |
b860f382 | 2709 | * Defining Packages:: Defining new packages. |
7458bd0a | 2710 | * Build Systems:: Specifying how packages are built. |
b860f382 LC |
2711 | * The Store:: Manipulating the package store. |
2712 | * Derivations:: Low-level interface to package derivations. | |
2713 | * The Store Monad:: Purely functional interface to the store. | |
21b679f6 | 2714 | * G-Expressions:: Manipulating build expressions. |
568717fd LC |
2715 | @end menu |
2716 | ||
2717 | @node Defining Packages | |
2718 | @section Defining Packages | |
2719 | ||
3dc1970d LC |
2720 | The high-level interface to package definitions is implemented in the |
2721 | @code{(guix packages)} and @code{(guix build-system)} modules. As an | |
2722 | example, the package definition, or @dfn{recipe}, for the GNU Hello | |
2723 | package looks like this: | |
2724 | ||
2725 | @example | |
e7f34eb0 LC |
2726 | (define-module (gnu packages hello) |
2727 | #:use-module (guix packages) | |
2728 | #:use-module (guix download) | |
2729 | #:use-module (guix build-system gnu) | |
a6dcdcac SB |
2730 | #:use-module (guix licenses) |
2731 | #:use-module (gnu packages gawk)) | |
b22a12fd | 2732 | |
79f5dd59 | 2733 | (define-public hello |
3dc1970d LC |
2734 | (package |
2735 | (name "hello") | |
17d8e33f | 2736 | (version "2.10") |
3dc1970d | 2737 | (source (origin |
17d8e33f ML |
2738 | (method url-fetch) |
2739 | (uri (string-append "mirror://gnu/hello/hello-" version | |
2740 | ".tar.gz")) | |
2741 | (sha256 | |
2742 | (base32 | |
2743 | "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))) | |
3dc1970d | 2744 | (build-system gnu-build-system) |
654c0d97 | 2745 | (arguments '(#:configure-flags '("--enable-silent-rules"))) |
3dc1970d | 2746 | (inputs `(("gawk" ,gawk))) |
7458bd0a LC |
2747 | (synopsis "Hello, GNU world: An example GNU package") |
2748 | (description "Guess what GNU Hello prints!") | |
3dc1970d | 2749 | (home-page "http://www.gnu.org/software/hello/") |
b22a12fd | 2750 | (license gpl3+))) |
3dc1970d LC |
2751 | @end example |
2752 | ||
2753 | @noindent | |
2754 | Without being a Scheme expert, the reader may have guessed the meaning | |
f97c9175 AE |
2755 | of the various fields here. This expression binds the variable |
2756 | @code{hello} to a @code{<package>} object, which is essentially a record | |
3dc1970d LC |
2757 | (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}). |
2758 | This package object can be inspected using procedures found in the | |
2759 | @code{(guix packages)} module; for instance, @code{(package-name hello)} | |
2760 | returns---surprise!---@code{"hello"}. | |
2761 | ||
2f7d2d91 LC |
2762 | With luck, you may be able to import part or all of the definition of |
2763 | the package you are interested in from another repository, using the | |
2764 | @code{guix import} command (@pxref{Invoking guix import}). | |
2765 | ||
f97c9175 | 2766 | In the example above, @var{hello} is defined in a module of its own, |
e7f34eb0 LC |
2767 | @code{(gnu packages hello)}. Technically, this is not strictly |
2768 | necessary, but it is convenient to do so: all the packages defined in | |
2769 | modules under @code{(gnu packages @dots{})} are automatically known to | |
2770 | the command-line tools (@pxref{Package Modules}). | |
2771 | ||
3dc1970d LC |
2772 | There are a few points worth noting in the above package definition: |
2773 | ||
2774 | @itemize | |
2775 | @item | |
a2bf4907 LC |
2776 | The @code{source} field of the package is an @code{<origin>} object |
2777 | (@pxref{origin Reference}, for the complete reference). | |
3dc1970d LC |
2778 | Here, the @code{url-fetch} method from @code{(guix download)} is used, |
2779 | meaning that the source is a file to be downloaded over FTP or HTTP. | |
2780 | ||
2781 | The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of | |
2782 | the GNU mirrors defined in @code{(guix download)}. | |
2783 | ||
2784 | The @code{sha256} field specifies the expected SHA256 hash of the file | |
2785 | being downloaded. It is mandatory, and allows Guix to check the | |
2786 | integrity of the file. The @code{(base32 @dots{})} form introduces the | |
6c365eca | 2787 | base32 representation of the hash. You can obtain this information with |
210cc920 LC |
2788 | @code{guix download} (@pxref{Invoking guix download}) and @code{guix |
2789 | hash} (@pxref{Invoking guix hash}). | |
3dc1970d | 2790 | |
f9cc8971 LC |
2791 | @cindex patches |
2792 | When needed, the @code{origin} form can also have a @code{patches} field | |
2793 | listing patches to be applied, and a @code{snippet} field giving a | |
2794 | Scheme expression to modify the source code. | |
2795 | ||
3dc1970d LC |
2796 | @item |
2797 | @cindex GNU Build System | |
7458bd0a LC |
2798 | The @code{build-system} field specifies the procedure to build the |
2799 | package (@pxref{Build Systems}). Here, @var{gnu-build-system} | |
2800 | represents the familiar GNU Build System, where packages may be | |
2801 | configured, built, and installed with the usual @code{./configure && | |
2802 | make && make check && make install} command sequence. | |
2803 | ||
2804 | @item | |
2805 | The @code{arguments} field specifies options for the build system | |
2806 | (@pxref{Build Systems}). Here it is interpreted by | |
2807 | @var{gnu-build-system} as a request run @file{configure} with the | |
2808 | @code{--enable-silent-rules} flag. | |
3dc1970d | 2809 | |
654c0d97 LC |
2810 | @cindex quote |
2811 | @cindex quoting | |
2812 | @findex ' | |
2813 | @findex quote | |
2814 | What about these quote (@code{'}) characters? They are Scheme syntax to | |
2815 | introduce a literal list; @code{'} is synonymous with @code{quote}. | |
2816 | @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual}, | |
2817 | for details. Here the value of the @code{arguments} field is a list of | |
2818 | arguments passed to the build system down the road, as with @code{apply} | |
2819 | (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference | |
2820 | Manual}). | |
2821 | ||
2822 | The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword} | |
2823 | (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and | |
2824 | @code{#:configure-flags} is a keyword used to pass a keyword argument | |
2825 | to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile | |
2826 | Reference Manual}). | |
2827 | ||
3dc1970d LC |
2828 | @item |
2829 | The @code{inputs} field specifies inputs to the build process---i.e., | |
2830 | build-time or run-time dependencies of the package. Here, we define an | |
2831 | input called @code{"gawk"} whose value is that of the @var{gawk} | |
2832 | variable; @var{gawk} is itself bound to a @code{<package>} object. | |
2833 | ||
654c0d97 LC |
2834 | @cindex backquote (quasiquote) |
2835 | @findex ` | |
2836 | @findex quasiquote | |
2837 | @cindex comma (unquote) | |
2838 | @findex , | |
2839 | @findex unquote | |
2840 | @findex ,@@ | |
2841 | @findex unquote-splicing | |
2842 | Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows | |
2843 | us to introduce a literal list in the @code{inputs} field, while | |
2844 | @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a | |
2845 | value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile | |
2846 | Reference Manual}). | |
2847 | ||
3dc1970d LC |
2848 | Note that GCC, Coreutils, Bash, and other essential tools do not need to |
2849 | be specified as inputs here. Instead, @var{gnu-build-system} takes care | |
7458bd0a | 2850 | of ensuring that they are present (@pxref{Build Systems}). |
3dc1970d LC |
2851 | |
2852 | However, any other dependencies need to be specified in the | |
2853 | @code{inputs} field. Any dependency not specified here will simply be | |
2854 | unavailable to the build process, possibly leading to a build failure. | |
2855 | @end itemize | |
2856 | ||
87eafdbd TUBK |
2857 | @xref{package Reference}, for a full description of possible fields. |
2858 | ||
2f7d2d91 | 2859 | Once a package definition is in place, the |
e49951eb | 2860 | package may actually be built using the @code{guix build} command-line |
39bee8a2 LC |
2861 | tool (@pxref{Invoking guix build}). You can easily jump back to the |
2862 | package definition using the @command{guix edit} command | |
2863 | (@pxref{Invoking guix edit}). | |
2864 | @xref{Packaging Guidelines}, for | |
b4f5e0e8 CR |
2865 | more information on how to test package definitions, and |
2866 | @ref{Invoking guix lint}, for information on how to check a definition | |
2867 | for style conformance. | |
2868 | ||
f97c9175 | 2869 | Finally, updating the package definition to a new upstream version |
7458bd0a LC |
2870 | can be partly automated by the @command{guix refresh} command |
2871 | (@pxref{Invoking guix refresh}). | |
3dc1970d LC |
2872 | |
2873 | Behind the scenes, a derivation corresponding to the @code{<package>} | |
2874 | object is first computed by the @code{package-derivation} procedure. | |
834129e0 | 2875 | That derivation is stored in a @code{.drv} file under @file{/gnu/store}. |
ba55b1cb | 2876 | The build actions it prescribes may then be realized by using the |
3dc1970d LC |
2877 | @code{build-derivations} procedure (@pxref{The Store}). |
2878 | ||
2879 | @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}] | |
59688fc4 LC |
2880 | Return the @code{<derivation>} object of @var{package} for @var{system} |
2881 | (@pxref{Derivations}). | |
3dc1970d LC |
2882 | |
2883 | @var{package} must be a valid @code{<package>} object, and @var{system} | |
2884 | must be a string denoting the target system type---e.g., | |
2885 | @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store} | |
2886 | must be a connection to the daemon, which operates on the store | |
2887 | (@pxref{The Store}). | |
2888 | @end deffn | |
568717fd | 2889 | |
9c1edabd LC |
2890 | @noindent |
2891 | @cindex cross-compilation | |
2892 | Similarly, it is possible to compute a derivation that cross-builds a | |
2893 | package for some other system: | |
2894 | ||
2895 | @deffn {Scheme Procedure} package-cross-derivation @var{store} @ | |
2896 | @var{package} @var{target} [@var{system}] | |
59688fc4 LC |
2897 | Return the @code{<derivation>} object of @var{package} cross-built from |
2898 | @var{system} to @var{target}. | |
9c1edabd LC |
2899 | |
2900 | @var{target} must be a valid GNU triplet denoting the target hardware | |
2901 | and operating system, such as @code{"mips64el-linux-gnu"} | |
2902 | (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU | |
2903 | Configure and Build System}). | |
2904 | @end deffn | |
2905 | ||
2a75b0b6 LC |
2906 | @cindex package transformations |
2907 | @cindex input rewriting | |
2908 | @cindex dependency tree rewriting | |
2909 | Packages can be manipulated in arbitrary ways. An example of a useful | |
2910 | transformation is @dfn{input rewriting}, whereby the dependency tree of | |
2911 | a package is rewritten by replacing specific inputs by others: | |
2912 | ||
2913 | @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @ | |
2914 | [@var{rewrite-name}] | |
2915 | Return a procedure that, when passed a package, replaces its direct and | |
2916 | indirect dependencies (but not its implicit inputs) according to | |
2917 | @var{replacements}. @var{replacements} is a list of package pairs; the | |
2918 | first element of each pair is the package to replace, and the second one | |
2919 | is the replacement. | |
2920 | ||
2921 | Optionally, @var{rewrite-name} is a one-argument procedure that takes | |
2922 | the name of a package and returns its new name after rewrite. | |
2923 | @end deffn | |
2924 | ||
2925 | @noindent | |
2926 | Consider this example: | |
2927 | ||
2928 | @example | |
2929 | (define libressl-instead-of-openssl | |
2930 | ;; This is a procedure to replace OPENSSL by LIBRESSL, | |
2931 | ;; recursively. | |
2932 | (package-input-rewriting `((,openssl . ,libressl)))) | |
2933 | ||
2934 | (define git-with-libressl | |
2935 | (libressl-instead-of-openssl git)) | |
2936 | @end example | |
2937 | ||
2938 | @noindent | |
2939 | Here we first define a rewriting procedure that replaces @var{openssl} | |
2940 | with @var{libressl}. Then we use it to define a @dfn{variant} of the | |
2941 | @var{git} package that uses @var{libressl} instead of @var{openssl}. | |
2942 | This is exactly what the @option{--with-input} command-line option does | |
2943 | (@pxref{Package Transformation Options, @option{--with-input}}). | |
2944 | ||
87eafdbd TUBK |
2945 | @menu |
2946 | * package Reference :: The package data type. | |
2947 | * origin Reference:: The origin data type. | |
2948 | @end menu | |
2949 | ||
2950 | ||
2951 | @node package Reference | |
2952 | @subsection @code{package} Reference | |
2953 | ||
2954 | This section summarizes all the options available in @code{package} | |
2955 | declarations (@pxref{Defining Packages}). | |
2956 | ||
2957 | @deftp {Data Type} package | |
2958 | This is the data type representing a package recipe. | |
2959 | ||
2960 | @table @asis | |
2961 | @item @code{name} | |
2962 | The name of the package, as a string. | |
2963 | ||
2964 | @item @code{version} | |
2965 | The version of the package, as a string. | |
2966 | ||
2967 | @item @code{source} | |
da675305 LC |
2968 | An object telling how the source code for the package should be |
2969 | acquired. Most of the time, this is an @code{origin} object, which | |
2970 | denotes a file fetched from the Internet (@pxref{origin Reference}). It | |
2971 | can also be any other ``file-like'' object such as a @code{local-file}, | |
2972 | which denotes a file from the local file system (@pxref{G-Expressions, | |
2973 | @code{local-file}}). | |
87eafdbd TUBK |
2974 | |
2975 | @item @code{build-system} | |
2976 | The build system that should be used to build the package (@pxref{Build | |
2977 | Systems}). | |
2978 | ||
2979 | @item @code{arguments} (default: @code{'()}) | |
2980 | The arguments that should be passed to the build system. This is a | |
2981 | list, typically containing sequential keyword-value pairs. | |
2982 | ||
2983 | @item @code{inputs} (default: @code{'()}) | |
70650c68 LC |
2984 | @itemx @code{native-inputs} (default: @code{'()}) |
2985 | @itemx @code{propagated-inputs} (default: @code{'()}) | |
2986 | @cindex inputs, of packages | |
2987 | These fields list dependencies of the package. Each one is a list of | |
2988 | tuples, where each tuple has a label for the input (a string) as its | |
2989 | first element, a package, origin, or derivation as its second element, | |
2990 | and optionally the name of the output thereof that should be used, which | |
2991 | defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for | |
f97c9175 | 2992 | more on package outputs). For example, the list below specifies three |
70650c68 | 2993 | inputs: |
87eafdbd | 2994 | |
70650c68 LC |
2995 | @example |
2996 | `(("libffi" ,libffi) | |
2997 | ("libunistring" ,libunistring) | |
2998 | ("glib:bin" ,glib "bin")) ;the "bin" output of Glib | |
2999 | @end example | |
3000 | ||
3001 | @cindex cross compilation, package dependencies | |
3002 | The distinction between @code{native-inputs} and @code{inputs} is | |
3003 | necessary when considering cross-compilation. When cross-compiling, | |
3004 | dependencies listed in @code{inputs} are built for the @emph{target} | |
3005 | architecture; conversely, dependencies listed in @code{native-inputs} | |
3006 | are built for the architecture of the @emph{build} machine. | |
3007 | ||
f97c9175 AE |
3008 | @code{native-inputs} is typically used to list tools needed at |
3009 | build time, but not at run time, such as Autoconf, Automake, pkg-config, | |
70650c68 LC |
3010 | Gettext, or Bison. @command{guix lint} can report likely mistakes in |
3011 | this area (@pxref{Invoking guix lint}). | |
3012 | ||
3013 | @anchor{package-propagated-inputs} | |
3014 | Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the | |
f97c9175 AE |
3015 | specified packages will be automatically installed alongside the package |
3016 | they belong to (@pxref{package-cmd-propagated-inputs, @command{guix | |
70650c68 LC |
3017 | package}}, for information on how @command{guix package} deals with |
3018 | propagated inputs.) | |
21461f27 | 3019 | |
e0508b6b LC |
3020 | For example this is necessary when a C/C++ library needs headers of |
3021 | another library to compile, or when a pkg-config file refers to another | |
3022 | one @i{via} its @code{Requires} field. | |
3023 | ||
f97c9175 AE |
3024 | Another example where @code{propagated-inputs} is useful is for languages |
3025 | that lack a facility to record the run-time search path akin to the | |
c8ebb4c4 | 3026 | @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and |
e0508b6b LC |
3027 | more. To ensure that libraries written in those languages can find |
3028 | library code they depend on at run time, run-time dependencies must be | |
3029 | listed in @code{propagated-inputs} rather than @code{inputs}. | |
87eafdbd | 3030 | |
87eafdbd TUBK |
3031 | @item @code{self-native-input?} (default: @code{#f}) |
3032 | This is a Boolean field telling whether the package should use itself as | |
3033 | a native input when cross-compiling. | |
3034 | ||
3035 | @item @code{outputs} (default: @code{'("out")}) | |
3036 | The list of output names of the package. @xref{Packages with Multiple | |
3037 | Outputs}, for typical uses of additional outputs. | |
3038 | ||
3039 | @item @code{native-search-paths} (default: @code{'()}) | |
3040 | @itemx @code{search-paths} (default: @code{'()}) | |
3041 | A list of @code{search-path-specification} objects describing | |
3042 | search-path environment variables honored by the package. | |
3043 | ||
3044 | @item @code{replacement} (default: @code{#f}) | |
f97c9175 | 3045 | This must be either @code{#f} or a package object that will be used as a |
87eafdbd TUBK |
3046 | @dfn{replacement} for this package. @xref{Security Updates, grafts}, |
3047 | for details. | |
3048 | ||
3049 | @item @code{synopsis} | |
3050 | A one-line description of the package. | |
3051 | ||
3052 | @item @code{description} | |
3053 | A more elaborate description of the package. | |
3054 | ||
3055 | @item @code{license} | |
e32171ee | 3056 | @cindex license, of packages |
f97c9175 AE |
3057 | The license of the package; a value from @code{(guix licenses)}, |
3058 | or a list of such values. | |
87eafdbd TUBK |
3059 | |
3060 | @item @code{home-page} | |
3061 | The URL to the home-page of the package, as a string. | |
3062 | ||
3063 | @item @code{supported-systems} (default: @var{%supported-systems}) | |
3064 | The list of systems supported by the package, as strings of the form | |
3065 | @code{architecture-kernel}, for example @code{"x86_64-linux"}. | |
3066 | ||
3067 | @item @code{maintainers} (default: @code{'()}) | |
3068 | The list of maintainers of the package, as @code{maintainer} objects. | |
3069 | ||
3070 | @item @code{location} (default: source location of the @code{package} form) | |
f97c9175 | 3071 | The source location of the package. It is useful to override this when |
87eafdbd TUBK |
3072 | inheriting from another package, in which case this field is not |
3073 | automatically corrected. | |
3074 | @end table | |
3075 | @end deftp | |
3076 | ||
3077 | ||
3078 | @node origin Reference | |
3079 | @subsection @code{origin} Reference | |
3080 | ||
3081 | This section summarizes all the options available in @code{origin} | |
3082 | declarations (@pxref{Defining Packages}). | |
3083 | ||
3084 | @deftp {Data Type} origin | |
3085 | This is the data type representing a source code origin. | |
3086 | ||
3087 | @table @asis | |
3088 | @item @code{uri} | |
3089 | An object containing the URI of the source. The object type depends on | |
3090 | the @code{method} (see below). For example, when using the | |
3091 | @var{url-fetch} method of @code{(guix download)}, the valid @code{uri} | |
3092 | values are: a URL represented as a string, or a list thereof. | |
3093 | ||
3094 | @item @code{method} | |
f97c9175 | 3095 | A procedure that handles the URI. |
87eafdbd TUBK |
3096 | |
3097 | Examples include: | |
3098 | ||
3099 | @table @asis | |
3100 | @item @var{url-fetch} from @code{(guix download)} | |
f97c9175 | 3101 | download a file from the HTTP, HTTPS, or FTP URL specified in the |
87eafdbd TUBK |
3102 | @code{uri} field; |
3103 | ||
db97a03a | 3104 | @vindex git-fetch |
87eafdbd TUBK |
3105 | @item @var{git-fetch} from @code{(guix git-download)} |
3106 | clone the Git version control repository, and check out the revision | |
3107 | specified in the @code{uri} field as a @code{git-reference} object; a | |
3108 | @code{git-reference} looks like this: | |
3109 | ||
3110 | @example | |
3111 | (git-reference | |
3112 | (url "git://git.debian.org/git/pkg-shadow/shadow") | |
3113 | (commit "v4.1.5.1")) | |
3114 | @end example | |
3115 | @end table | |
3116 | ||
3117 | @item @code{sha256} | |
3118 | A bytevector containing the SHA-256 hash of the source. Typically the | |
3119 | @code{base32} form is used here to generate the bytevector from a | |
3120 | base-32 string. | |
3121 | ||
db97a03a LC |
3122 | You can obtain this information using @code{guix download} |
3123 | (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking | |
3124 | guix hash}). | |
3125 | ||
87eafdbd TUBK |
3126 | @item @code{file-name} (default: @code{#f}) |
3127 | The file name under which the source code should be saved. When this is | |
3128 | @code{#f}, a sensible default value will be used in most cases. In case | |
3129 | the source is fetched from a URL, the file name from the URL will be | |
f97c9175 | 3130 | used. For version control checkouts, it is recommended to provide the |
87eafdbd TUBK |
3131 | file name explicitly because the default is not very descriptive. |
3132 | ||
3133 | @item @code{patches} (default: @code{'()}) | |
3134 | A list of file names containing patches to be applied to the source. | |
3135 | ||
0dfebdaa LC |
3136 | This list of patches must be unconditional. In particular, it cannot |
3137 | depend on the value of @code{%current-system} or | |
3138 | @code{%current-target-system}. | |
3139 | ||
87eafdbd | 3140 | @item @code{snippet} (default: @code{#f}) |
1929fdba LC |
3141 | A G-expression (@pxref{G-Expressions}) or S-expression that will be run |
3142 | in the source directory. This is a convenient way to modify the source, | |
3143 | sometimes more convenient than a patch. | |
87eafdbd TUBK |
3144 | |
3145 | @item @code{patch-flags} (default: @code{'("-p1")}) | |
3146 | A list of command-line flags that should be passed to the @code{patch} | |
3147 | command. | |
3148 | ||
3149 | @item @code{patch-inputs} (default: @code{#f}) | |
3150 | Input packages or derivations to the patching process. When this is | |
3151 | @code{#f}, the usual set of inputs necessary for patching are provided, | |
3152 | such as GNU@tie{}Patch. | |
3153 | ||
3154 | @item @code{modules} (default: @code{'()}) | |
3155 | A list of Guile modules that should be loaded during the patching | |
3156 | process and while running the code in the @code{snippet} field. | |
3157 | ||
87eafdbd TUBK |
3158 | @item @code{patch-guile} (default: @code{#f}) |
3159 | The Guile package that should be used in the patching process. When | |
3160 | this is @code{#f}, a sensible default is used. | |
3161 | @end table | |
3162 | @end deftp | |
3163 | ||
9c1edabd | 3164 | |
7458bd0a LC |
3165 | @node Build Systems |
3166 | @section Build Systems | |
3167 | ||
3168 | @cindex build system | |
3169 | Each package definition specifies a @dfn{build system} and arguments for | |
3170 | that build system (@pxref{Defining Packages}). This @code{build-system} | |
f97c9175 | 3171 | field represents the build procedure of the package, as well as implicit |
7458bd0a LC |
3172 | dependencies of that build procedure. |
3173 | ||
3174 | Build systems are @code{<build-system>} objects. The interface to | |
3175 | create and manipulate them is provided by the @code{(guix build-system)} | |
3176 | module, and actual build systems are exported by specific modules. | |
3177 | ||
f5fd4fd2 | 3178 | @cindex bag (low-level package representation) |
0d5a559f LC |
3179 | Under the hood, build systems first compile package objects to |
3180 | @dfn{bags}. A @dfn{bag} is like a package, but with less | |
3181 | ornamentation---in other words, a bag is a lower-level representation of | |
3182 | a package, which includes all the inputs of that package, including some | |
3183 | that were implicitly added by the build system. This intermediate | |
3184 | representation is then compiled to a derivation (@pxref{Derivations}). | |
3185 | ||
7458bd0a LC |
3186 | Build systems accept an optional list of @dfn{arguments}. In package |
3187 | definitions, these are passed @i{via} the @code{arguments} field | |
3188 | (@pxref{Defining Packages}). They are typically keyword arguments | |
3189 | (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU | |
3190 | Guile Reference Manual}). The value of these arguments is usually | |
3191 | evaluated in the @dfn{build stratum}---i.e., by a Guile process launched | |
3192 | by the daemon (@pxref{Derivations}). | |
3193 | ||
3194 | The main build system is @var{gnu-build-system}, which implements the | |
f97c9175 | 3195 | standard build procedure for GNU and many other packages. It |
7458bd0a LC |
3196 | is provided by the @code{(guix build-system gnu)} module. |
3197 | ||
3198 | @defvr {Scheme Variable} gnu-build-system | |
3199 | @var{gnu-build-system} represents the GNU Build System, and variants | |
3200 | thereof (@pxref{Configuration, configuration and makefile conventions,, | |
3201 | standards, GNU Coding Standards}). | |
3202 | ||
3203 | @cindex build phases | |
f97c9175 | 3204 | In a nutshell, packages using it are configured, built, and installed with |
7458bd0a LC |
3205 | the usual @code{./configure && make && make check && make install} |
3206 | command sequence. In practice, a few additional steps are often needed. | |
3207 | All these steps are split up in separate @dfn{phases}, | |
3208 | notably@footnote{Please see the @code{(guix build gnu-build-system)} | |
3209 | modules for more details about the build phases.}: | |
3210 | ||
3211 | @table @code | |
3212 | @item unpack | |
3213 | Unpack the source tarball, and change the current directory to the | |
3214 | extracted source tree. If the source is actually a directory, copy it | |
3215 | to the build tree, and enter that directory. | |
3216 | ||
3217 | @item patch-source-shebangs | |
3218 | Patch shebangs encountered in source files so they refer to the right | |
3219 | store file names. For instance, this changes @code{#!/bin/sh} to | |
3220 | @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}. | |
3221 | ||
3222 | @item configure | |
3223 | Run the @file{configure} script with a number of default options, such | |
3224 | as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified | |
3225 | by the @code{#:configure-flags} argument. | |
3226 | ||
3227 | @item build | |
3228 | Run @code{make} with the list of flags specified with | |
0917e80e | 3229 | @code{#:make-flags}. If the @code{#:parallel-build?} argument is true |
7458bd0a LC |
3230 | (the default), build with @code{make -j}. |
3231 | ||
3232 | @item check | |
3233 | Run @code{make check}, or some other target specified with | |
3234 | @code{#:test-target}, unless @code{#:tests? #f} is passed. If the | |
3235 | @code{#:parallel-tests?} argument is true (the default), run @code{make | |
3236 | check -j}. | |
3237 | ||
3238 | @item install | |
3239 | Run @code{make install} with the flags listed in @code{#:make-flags}. | |
3240 | ||
3241 | @item patch-shebangs | |
3242 | Patch shebangs on the installed executable files. | |
3243 | ||
3244 | @item strip | |
3245 | Strip debugging symbols from ELF files (unless @code{#:strip-binaries?} | |
3246 | is false), copying them to the @code{debug} output when available | |
3247 | (@pxref{Installing Debugging Files}). | |
3248 | @end table | |
3249 | ||
3250 | @vindex %standard-phases | |
3251 | The build-side module @code{(guix build gnu-build-system)} defines | |
3252 | @var{%standard-phases} as the default list of build phases. | |
3253 | @var{%standard-phases} is a list of symbol/procedure pairs, where the | |
3254 | procedure implements the actual phase. | |
3255 | ||
3256 | The list of phases used for a particular package can be changed with the | |
3257 | @code{#:phases} parameter. For instance, passing: | |
3258 | ||
3259 | @example | |
c2c5dc79 | 3260 | #:phases (modify-phases %standard-phases (delete 'configure)) |
7458bd0a LC |
3261 | @end example |
3262 | ||
9bf404e9 | 3263 | means that all the phases described above will be used, except the |
7458bd0a LC |
3264 | @code{configure} phase. |
3265 | ||
3266 | In addition, this build system ensures that the ``standard'' environment | |
3267 | for GNU packages is available. This includes tools such as GCC, libc, | |
3268 | Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix | |
f97c9175 AE |
3269 | build-system gnu)} module for a complete list). We call these the |
3270 | @dfn{implicit inputs} of a package, because package definitions do not | |
7458bd0a LC |
3271 | have to mention them. |
3272 | @end defvr | |
3273 | ||
3274 | Other @code{<build-system>} objects are defined to support other | |
3275 | conventions and tools used by free software packages. They inherit most | |
3276 | of @var{gnu-build-system}, and differ mainly in the set of inputs | |
3277 | implicitly added to the build process, and in the list of phases | |
3278 | executed. Some of these build systems are listed below. | |
3279 | ||
5f7a1a4d RW |
3280 | @defvr {Scheme Variable} ant-build-system |
3281 | This variable is exported by @code{(guix build-system ant)}. It | |
3282 | implements the build procedure for Java packages that can be built with | |
3283 | @url{http://ant.apache.org/, Ant build tool}. | |
3284 | ||
3285 | It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as | |
3286 | provided by the @code{icedtea} package to the set of inputs. Different | |
3287 | packages can be specified with the @code{#:ant} and @code{#:jdk} | |
3288 | parameters, respectively. | |
3289 | ||
3290 | When the original package does not provide a suitable Ant build file, | |
3291 | the parameter @code{#:jar-name} can be used to generate a minimal Ant | |
3292 | build file @file{build.xml} with tasks to build the specified jar | |
3293 | archive. | |
3294 | ||
3295 | The parameter @code{#:build-target} can be used to specify the Ant task | |
3296 | that should be run during the @code{build} phase. By default the | |
3297 | ``jar'' task will be run. | |
3298 | ||
3299 | @end defvr | |
3300 | ||
a1b30f99 AP |
3301 | @defvr {Scheme Variable} asdf-build-system/source |
3302 | @defvrx {Scheme Variable} asdf-build-system/sbcl | |
3303 | @defvrx {Scheme Variable} asdf-build-system/ecl | |
3304 | ||
3305 | These variables, exported by @code{(guix build-system asdf)}, implement | |
3306 | build procedures for Common Lisp packages using | |
3307 | @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system | |
3308 | definition facility for Common Lisp programs and libraries. | |
3309 | ||
3310 | The @code{asdf-build-system/source} system installs the packages in | |
3311 | source form, and can be loaded using any common lisp implementation, via | |
3312 | ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary | |
3313 | systems in the format which a particular implementation understands. | |
3314 | These build systems can also be used to produce executable programs, or | |
3315 | lisp images which contain a set of packages pre-loaded. | |
3316 | ||
3317 | The build system uses naming conventions. For binary packages, the | |
3318 | package itself as well as its run-time dependencies should begin their | |
3319 | name with the lisp implementation, such as @code{sbcl-} for | |
3320 | @code{asdf-build-system/sbcl}. Beginning the input name with this | |
3321 | prefix will allow the build system to encode its location into the | |
3322 | resulting library, so that the input can be found at run-time. | |
3323 | ||
3324 | If dependencies are used only for tests, it is convenient to use a | |
3325 | different prefix in order to avoid having a run-time dependency on such | |
3326 | systems. For example, | |
3327 | ||
3328 | @example | |
3329 | (define-public sbcl-bordeaux-threads | |
3330 | (package | |
3331 | ... | |
3332 | (native-inputs `(("tests:cl-fiveam" ,sbcl-fiveam))) | |
3333 | ...)) | |
3334 | @end example | |
3335 | ||
3336 | Additionally, the corresponding source package should be labeled using | |
3337 | the same convention as python packages (see @ref{Python Modules}), using | |
3338 | the @code{cl-} prefix. | |
3339 | ||
3340 | For binary packages, each system should be defined as a Guix package. | |
3341 | If one package @code{origin} contains several systems, package variants | |
3342 | can be created in order to build all the systems. Source packages, | |
3343 | which use @code{asdf-build-system/source}, may contain several systems. | |
3344 | ||
3345 | In order to create executable programs and images, the build-side | |
3346 | procedures @code{build-program} and @code{build-image} can be used. | |
3347 | They should be called in a build phase after the @code{create-symlinks} | |
3348 | phase, so that the system which was just built can be used within the | |
3349 | resulting image. @code{build-program} requires a list of Common Lisp | |
3350 | expressions to be passed as the @code{#:entry-program} argument. | |
3351 | ||
3352 | If the system is not defined within its own @code{.asd} file of the same | |
3353 | name, then the @code{#:asd-file} parameter should be used to specify | |
3354 | which file the system is defined in. | |
3355 | ||
3356 | @end defvr | |
3357 | ||
1ec34dd7 LC |
3358 | @defvr {Scheme Variable} cargo-build-system |
3359 | @cindex Rust programming language | |
3360 | @cindex Cargo (Rust build system) | |
3361 | This variable is exported by @code{(guix build-system cargo)}. It | |
3362 | supports builds of packages using Cargo, the build tool of the | |
3363 | @uref{https://www.rust-lang.org, Rust programming language}. | |
3364 | ||
3365 | In its @code{configure} phase, this build system replaces dependencies | |
3366 | specified in the @file{Carto.toml} file with inputs to the Guix package. | |
3367 | The @code{install} phase installs the binaries, and it also installs the | |
3368 | source code and @file{Cargo.toml} file. | |
3369 | @end defvr | |
3370 | ||
7458bd0a LC |
3371 | @defvr {Scheme Variable} cmake-build-system |
3372 | This variable is exported by @code{(guix build-system cmake)}. It | |
3373 | implements the build procedure for packages using the | |
3374 | @url{http://www.cmake.org, CMake build tool}. | |
3375 | ||
3376 | It automatically adds the @code{cmake} package to the set of inputs. | |
3377 | Which package is used can be specified with the @code{#:cmake} | |
3378 | parameter. | |
9849cfc1 LC |
3379 | |
3380 | The @code{#:configure-flags} parameter is taken as a list of flags | |
3381 | passed to the @command{cmake} command. The @code{#:build-type} | |
3382 | parameter specifies in abstract terms the flags passed to the compiler; | |
3383 | it defaults to @code{"RelWithDebInfo"} (short for ``release mode with | |
3384 | debugging information''), which roughly means that code is compiled with | |
3385 | @code{-O2 -g}, as is the case for Autoconf-based packages by default. | |
7458bd0a LC |
3386 | @end defvr |
3387 | ||
3afcf52b FB |
3388 | @defvr {Scheme Variable} glib-or-gtk-build-system |
3389 | This variable is exported by @code{(guix build-system glib-or-gtk)}. It | |
3390 | is intended for use with packages making use of GLib or GTK+. | |
3391 | ||
3392 | This build system adds the following two phases to the ones defined by | |
3393 | @var{gnu-build-system}: | |
3394 | ||
3395 | @table @code | |
3396 | @item glib-or-gtk-wrap | |
f97c9175 AE |
3397 | The phase @code{glib-or-gtk-wrap} ensures that programs in |
3398 | @file{bin/} are able to find GLib ``schemas'' and | |
3afcf52b FB |
3399 | @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+ |
3400 | modules}. This is achieved by wrapping the programs in launch scripts | |
3401 | that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH} | |
3402 | environment variables. | |
3403 | ||
73aa8ddb LC |
3404 | It is possible to exclude specific package outputs from that wrapping |
3405 | process by listing their names in the | |
3406 | @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful | |
3407 | when an output is known not to contain any GLib or GTK+ binaries, and | |
3408 | where wrapping would gratuitously add a dependency of that output on | |
3409 | GLib and GTK+. | |
3410 | ||
3afcf52b | 3411 | @item glib-or-gtk-compile-schemas |
f97c9175 | 3412 | The phase @code{glib-or-gtk-compile-schemas} makes sure that all |
3afcf52b | 3413 | @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html, |
f97c9175 | 3414 | GSettings schemas} of GLib are compiled. Compilation is performed by the |
3afcf52b FB |
3415 | @command{glib-compile-schemas} program. It is provided by the package |
3416 | @code{glib:bin} which is automatically imported by the build system. | |
3417 | The @code{glib} package providing @command{glib-compile-schemas} can be | |
3418 | specified with the @code{#:glib} parameter. | |
3419 | @end table | |
3420 | ||
3421 | Both phases are executed after the @code{install} phase. | |
3422 | @end defvr | |
3423 | ||
3184f14a JL |
3424 | @defvr {Scheme Variable} ocaml-build-system |
3425 | This variable is exported by @code{(guix build-sytem ocaml)}. It implements | |
3426 | a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists | |
3427 | of choosing the correct set of commands to run for each package. OCaml | |
3428 | packages can expect many different commands to be run. This build system will | |
3429 | try some of them. | |
3430 | ||
3431 | When the package has a @file{setup.ml} file present at the top-level, it will | |
3432 | run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and | |
3433 | @code{ocaml setup.ml -install}. The build system will assume that this file | |
3434 | was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take | |
3435 | care of setting the prefix and enabling tests if they are not disabled. You | |
3436 | can pass configure and build flags with the @code{#:configure-flags} and | |
3437 | @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the | |
3438 | set of flags used to enable tests. The @code{#:use-make?} key can be used to | |
3439 | bypass this system in the build and install phases. | |
3440 | ||
3441 | When the package has a @file{configure} file, it is assumed that it is a | |
3442 | hand-made configure script that requires a different argument format than | |
3443 | in the @code{gnu-build-system}. You can add more flags with the | |
3444 | @code{#:configure-flags} key. | |
3445 | ||
3446 | When the package has a @file{Makefile} file (or @code{#:use-make?} is | |
3447 | @code{#t}), it will be used and more flags can be passed to the build and | |
3448 | install phases with the @code{#:make-flags} key. | |
3449 | ||
3450 | Finally, some packages do not have these files and use a somewhat standard | |
3451 | location for its build system. In that case, the build system will run | |
3452 | @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of | |
3453 | providing the path to the required findlib module. Additional flags can | |
3454 | be passed via the @code{#:build-flags} key. Install is taken care of by | |
3455 | @command{opam-installer}. In this case, the @code{opam} package must | |
3456 | be added to the @code{native-inputs} field of the package definition. | |
3457 | ||
3458 | Note that most OCaml packages assume they will be installed in the same | |
88ba7852 | 3459 | directory as OCaml, which is not what we want in guix. In particular, they |
3184f14a | 3460 | will install @file{.so} files in their module's directory, which is usually |
88ba7852 | 3461 | fine because it is in the OCaml compiler directory. In guix though, these |
3184f14a JL |
3462 | libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This |
3463 | variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where | |
3464 | @file{.so} libraries should be installed. | |
3465 | @end defvr | |
3466 | ||
7458bd0a LC |
3467 | @defvr {Scheme Variable} python-build-system |
3468 | This variable is exported by @code{(guix build-system python)}. It | |
3469 | implements the more or less standard build procedure used by Python | |
3470 | packages, which consists in running @code{python setup.py build} and | |
3471 | then @code{python setup.py install --prefix=/gnu/store/@dots{}}. | |
3472 | ||
3473 | For packages that install stand-alone Python programs under @code{bin/}, | |
f97c9175 | 3474 | it takes care of wrapping these programs so that their @code{PYTHONPATH} |
7458bd0a LC |
3475 | environment variable points to all the Python libraries they depend on. |
3476 | ||
8a46205b CM |
3477 | Which Python package is used to perform the build can be specified with |
3478 | the @code{#:python} parameter. This is a useful way to force a package | |
3479 | to be built for a specific version of the Python interpreter, which | |
3480 | might be necessary if the package is only compatible with a single | |
3481 | interpreter version. | |
5f7565d1 HG |
3482 | |
3483 | By default guix calls @code{setup.py} under control of | |
3484 | @code{setuptools}, much like @command{pip} does. Some packages are not | |
3485 | compatible with setuptools (and pip), thus you can disable this by | |
3486 | setting the @code{#:use-setuptools} parameter to @code{#f}. | |
7458bd0a LC |
3487 | @end defvr |
3488 | ||
3489 | @defvr {Scheme Variable} perl-build-system | |
3490 | This variable is exported by @code{(guix build-system perl)}. It | |
2d2a53fc EB |
3491 | implements the standard build procedure for Perl packages, which either |
3492 | consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}}, | |
3493 | followed by @code{Build} and @code{Build install}; or in running | |
3494 | @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by | |
f97c9175 | 3495 | @code{make} and @code{make install}, depending on which of |
2d2a53fc EB |
3496 | @code{Build.PL} or @code{Makefile.PL} is present in the package |
3497 | distribution. Preference is given to the former if both @code{Build.PL} | |
3498 | and @code{Makefile.PL} exist in the package distribution. This | |
3499 | preference can be reversed by specifying @code{#t} for the | |
3500 | @code{#:make-maker?} parameter. | |
3501 | ||
3502 | The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation | |
3503 | passes flags specified by the @code{#:make-maker-flags} or | |
3504 | @code{#:module-build-flags} parameter, respectively. | |
7458bd0a LC |
3505 | |
3506 | Which Perl package is used can be specified with @code{#:perl}. | |
3507 | @end defvr | |
3508 | ||
f8f3bef6 RW |
3509 | @defvr {Scheme Variable} r-build-system |
3510 | This variable is exported by @code{(guix build-system r)}. It | |
3511 | implements the build procedure used by @uref{http://r-project.org, R} | |
3512 | packages, which essentially is little more than running @code{R CMD | |
3513 | INSTALL --library=/gnu/store/@dots{}} in an environment where | |
3514 | @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests | |
3515 | are run after installation using the R function | |
3516 | @code{tools::testInstalledPackage}. | |
3517 | @end defvr | |
3518 | ||
c08f9818 DT |
3519 | @defvr {Scheme Variable} ruby-build-system |
3520 | This variable is exported by @code{(guix build-system ruby)}. It | |
3521 | implements the RubyGems build procedure used by Ruby packages, which | |
3522 | involves running @code{gem build} followed by @code{gem install}. | |
3523 | ||
5dc87623 DT |
3524 | The @code{source} field of a package that uses this build system |
3525 | typically references a gem archive, since this is the format that Ruby | |
3526 | developers use when releasing their software. The build system unpacks | |
3527 | the gem archive, potentially patches the source, runs the test suite, | |
3528 | repackages the gem, and installs it. Additionally, directories and | |
3529 | tarballs may be referenced to allow building unreleased gems from Git or | |
3530 | a traditional source release tarball. | |
e83c6d00 | 3531 | |
c08f9818 | 3532 | Which Ruby package is used can be specified with the @code{#:ruby} |
6e9f2913 PP |
3533 | parameter. A list of additional flags to be passed to the @command{gem} |
3534 | command can be specified with the @code{#:gem-flags} parameter. | |
c08f9818 | 3535 | @end defvr |
7458bd0a | 3536 | |
a677c726 RW |
3537 | @defvr {Scheme Variable} waf-build-system |
3538 | This variable is exported by @code{(guix build-system waf)}. It | |
3539 | implements a build procedure around the @code{waf} script. The common | |
3540 | phases---@code{configure}, @code{build}, and @code{install}---are | |
3541 | implemented by passing their names as arguments to the @code{waf} | |
3542 | script. | |
3543 | ||
3544 | The @code{waf} script is executed by the Python interpreter. Which | |
3545 | Python package is used to run the script can be specified with the | |
3546 | @code{#:python} parameter. | |
3547 | @end defvr | |
3548 | ||
14dfdf2e FB |
3549 | @defvr {Scheme Variable} haskell-build-system |
3550 | This variable is exported by @code{(guix build-system haskell)}. It | |
3551 | implements the Cabal build procedure used by Haskell packages, which | |
3552 | involves running @code{runhaskell Setup.hs configure | |
3553 | --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}. | |
3554 | Instead of installing the package by running @code{runhaskell Setup.hs | |
3555 | install}, to avoid trying to register libraries in the read-only | |
3556 | compiler store directory, the build system uses @code{runhaskell | |
3557 | Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In | |
3558 | addition, the build system generates the package documentation by | |
3559 | running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f} | |
3560 | is passed. Optional Haddock parameters can be passed with the help of | |
3561 | the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is | |
3562 | not found, the build system looks for @code{Setup.lhs} instead. | |
3563 | ||
3564 | Which Haskell compiler is used can be specified with the @code{#:haskell} | |
a54bd6d7 | 3565 | parameter which defaults to @code{ghc}. |
14dfdf2e FB |
3566 | @end defvr |
3567 | ||
65e862d1 DM |
3568 | @defvr {Scheme Variable} dub-build-system |
3569 | This variable is exported by @code{(guix build-system dub)}. It | |
3570 | implements the Dub build procedure used by D packages, which | |
3571 | involves running @code{dub build} and @code{dub run}. | |
3572 | Installation is done by copying the files manually. | |
3573 | ||
3574 | Which D compiler is used can be specified with the @code{#:ldc} | |
3575 | parameter which defaults to @code{ldc}. | |
3576 | @end defvr | |
3577 | ||
e9137a53 FB |
3578 | @defvr {Scheme Variable} emacs-build-system |
3579 | This variable is exported by @code{(guix build-system emacs)}. It | |
f97c9175 AE |
3580 | implements an installation procedure similar to the packaging system |
3581 | of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}). | |
e9137a53 FB |
3582 | |
3583 | It first creates the @code{@var{package}-autoloads.el} file, then it | |
3584 | byte compiles all Emacs Lisp files. Differently from the Emacs | |
3585 | packaging system, the Info documentation files are moved to the standard | |
3586 | documentation directory and the @file{dir} file is deleted. Each | |
3587 | package is installed in its own directory under | |
3588 | @file{share/emacs/site-lisp/guix.d}. | |
3589 | @end defvr | |
3590 | ||
7458bd0a LC |
3591 | Lastly, for packages that do not need anything as sophisticated, a |
3592 | ``trivial'' build system is provided. It is trivial in the sense that | |
3593 | it provides basically no support: it does not pull any implicit inputs, | |
3594 | and does not have a notion of build phases. | |
3595 | ||
3596 | @defvr {Scheme Variable} trivial-build-system | |
3597 | This variable is exported by @code{(guix build-system trivial)}. | |
3598 | ||
3599 | This build system requires a @code{#:builder} argument. This argument | |
f97c9175 | 3600 | must be a Scheme expression that builds the package output(s)---as |
7458bd0a LC |
3601 | with @code{build-expression->derivation} (@pxref{Derivations, |
3602 | @code{build-expression->derivation}}). | |
3603 | @end defvr | |
3604 | ||
568717fd LC |
3605 | @node The Store |
3606 | @section The Store | |
3607 | ||
e531ac2a | 3608 | @cindex store |
1ddee424 | 3609 | @cindex store items |
e531ac2a LC |
3610 | @cindex store paths |
3611 | ||
f97c9175 AE |
3612 | Conceptually, the @dfn{store} is the place where derivations that have |
3613 | been built successfully are stored---by default, @file{/gnu/store}. | |
1ddee424 LC |
3614 | Sub-directories in the store are referred to as @dfn{store items} or |
3615 | sometimes @dfn{store paths}. The store has an associated database that | |
3616 | contains information such as the store paths referred to by each store | |
3617 | path, and the list of @emph{valid} store items---results of successful | |
ef5f5c86 LC |
3618 | builds. This database resides in @file{@var{localstatedir}/guix/db}, |
3619 | where @var{localstatedir} is the state directory specified @i{via} | |
3620 | @option{--localstatedir} at configure time, usually @file{/var}. | |
1ddee424 LC |
3621 | |
3622 | The store is @emph{always} accessed by the daemon on behalf of its clients | |
e531ac2a | 3623 | (@pxref{Invoking guix-daemon}). To manipulate the store, clients |
f97c9175 AE |
3624 | connect to the daemon over a Unix-domain socket, send requests to it, |
3625 | and read the result---these are remote procedure calls, or RPCs. | |
e531ac2a | 3626 | |
1ddee424 LC |
3627 | @quotation Note |
3628 | Users must @emph{never} modify files under @file{/gnu/store} directly. | |
3629 | This would lead to inconsistencies and break the immutability | |
3630 | assumptions of Guix's functional model (@pxref{Introduction}). | |
3631 | ||
3632 | @xref{Invoking guix gc, @command{guix gc --verify}}, for information on | |
3633 | how to check the integrity of the store and attempt recovery from | |
3634 | accidental modifications. | |
3635 | @end quotation | |
3636 | ||
e531ac2a LC |
3637 | The @code{(guix store)} module provides procedures to connect to the |
3638 | daemon, and to perform RPCs. These are described below. | |
3639 | ||
3640 | @deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t] | |
3641 | Connect to the daemon over the Unix-domain socket at @var{file}. When | |
3642 | @var{reserve-space?} is true, instruct it to reserve a little bit of | |
3643 | extra space on the file system so that the garbage collector can still | |
f97c9175 | 3644 | operate should the disk become full. Return a server object. |
e531ac2a LC |
3645 | |
3646 | @var{file} defaults to @var{%default-socket-path}, which is the normal | |
3647 | location given the options that were passed to @command{configure}. | |
3648 | @end deffn | |
3649 | ||
3650 | @deffn {Scheme Procedure} close-connection @var{server} | |
3651 | Close the connection to @var{server}. | |
3652 | @end deffn | |
3653 | ||
3654 | @defvr {Scheme Variable} current-build-output-port | |
3655 | This variable is bound to a SRFI-39 parameter, which refers to the port | |
3656 | where build and error logs sent by the daemon should be written. | |
3657 | @end defvr | |
3658 | ||
3659 | Procedures that make RPCs all take a server object as their first | |
3660 | argument. | |
3661 | ||
3662 | @deffn {Scheme Procedure} valid-path? @var{server} @var{path} | |
06b76acc LC |
3663 | @cindex invalid store items |
3664 | Return @code{#t} when @var{path} designates a valid store item and | |
3665 | @code{#f} otherwise (an invalid item may exist on disk but still be | |
3666 | invalid, for instance because it is the result of an aborted or failed | |
3667 | build.) | |
3668 | ||
3669 | A @code{&nix-protocol-error} condition is raised if @var{path} is not | |
3670 | prefixed by the store directory (@file{/gnu/store}). | |
e531ac2a LC |
3671 | @end deffn |
3672 | ||
cfbf9160 | 3673 | @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}] |
e531ac2a LC |
3674 | Add @var{text} under file @var{name} in the store, and return its store |
3675 | path. @var{references} is the list of store paths referred to by the | |
3676 | resulting store path. | |
3677 | @end deffn | |
3678 | ||
874e6874 | 3679 | @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations} |
59688fc4 LC |
3680 | Build @var{derivations} (a list of @code{<derivation>} objects or |
3681 | derivation paths), and return when the worker is done building them. | |
3682 | Return @code{#t} on success. | |
874e6874 LC |
3683 | @end deffn |
3684 | ||
b860f382 LC |
3685 | Note that the @code{(guix monads)} module provides a monad as well as |
3686 | monadic versions of the above procedures, with the goal of making it | |
3687 | more convenient to work with code that accesses the store (@pxref{The | |
3688 | Store Monad}). | |
3689 | ||
e531ac2a LC |
3690 | @c FIXME |
3691 | @i{This section is currently incomplete.} | |
568717fd LC |
3692 | |
3693 | @node Derivations | |
3694 | @section Derivations | |
3695 | ||
874e6874 LC |
3696 | @cindex derivations |
3697 | Low-level build actions and the environment in which they are performed | |
70458ed5 | 3698 | are represented by @dfn{derivations}. A derivation contains the |
874e6874 LC |
3699 | following pieces of information: |
3700 | ||
3701 | @itemize | |
3702 | @item | |
3703 | The outputs of the derivation---derivations produce at least one file or | |
3704 | directory in the store, but may produce more. | |
3705 | ||
3706 | @item | |
3707 | The inputs of the derivations, which may be other derivations or plain | |
3708 | files in the store (patches, build scripts, etc.) | |
3709 | ||
3710 | @item | |
3711 | The system type targeted by the derivation---e.g., @code{x86_64-linux}. | |
3712 | ||
3713 | @item | |
3714 | The file name of a build script in the store, along with the arguments | |
3715 | to be passed. | |
3716 | ||
3717 | @item | |
3718 | A list of environment variables to be defined. | |
3719 | ||
3720 | @end itemize | |
3721 | ||
3722 | @cindex derivation path | |
3723 | Derivations allow clients of the daemon to communicate build actions to | |
3724 | the store. They exist in two forms: as an in-memory representation, | |
3725 | both on the client- and daemon-side, and as files in the store whose | |
3726 | name end in @code{.drv}---these files are referred to as @dfn{derivation | |
3727 | paths}. Derivations paths can be passed to the @code{build-derivations} | |
3728 | procedure to perform the build actions they prescribe (@pxref{The | |
3729 | Store}). | |
3730 | ||
3731 | The @code{(guix derivations)} module provides a representation of | |
3732 | derivations as Scheme objects, along with procedures to create and | |
3733 | otherwise manipulate derivations. The lowest-level primitive to create | |
3734 | a derivation is the @code{derivation} procedure: | |
3735 | ||
1909431c LC |
3736 | @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @ |
3737 | @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
2096ef47 | 3738 | [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @ |
1909431c | 3739 | [#:system (%current-system)] [#:references-graphs #f] @ |
35b5ca78 LC |
3740 | [#:allowed-references #f] [#:disallowed-references #f] @ |
3741 | [#:leaked-env-vars #f] [#:local-build? #f] @ | |
4a6aeb67 | 3742 | [#:substitutable? #t] |
59688fc4 LC |
3743 | Build a derivation with the given arguments, and return the resulting |
3744 | @code{<derivation>} object. | |
874e6874 | 3745 | |
2096ef47 | 3746 | When @var{hash} and @var{hash-algo} are given, a |
874e6874 | 3747 | @dfn{fixed-output derivation} is created---i.e., one whose result is |
36bbbbd1 LC |
3748 | known in advance, such as a file download. If, in addition, |
3749 | @var{recursive?} is true, then that fixed output may be an executable | |
3750 | file or a directory and @var{hash} must be the hash of an archive | |
3751 | containing this output. | |
5b0c9d16 | 3752 | |
858e9282 | 3753 | When @var{references-graphs} is true, it must be a list of file |
5b0c9d16 LC |
3754 | name/store path pairs. In that case, the reference graph of each store |
3755 | path is exported in the build environment in the corresponding file, in | |
3756 | a simple text format. | |
1909431c | 3757 | |
b53be755 | 3758 | When @var{allowed-references} is true, it must be a list of store items |
35b5ca78 LC |
3759 | or outputs that the derivation's output may refer to. Likewise, |
3760 | @var{disallowed-references}, if true, must be a list of things the | |
3761 | outputs may @emph{not} refer to. | |
b53be755 | 3762 | |
c0468155 LC |
3763 | When @var{leaked-env-vars} is true, it must be a list of strings |
3764 | denoting environment variables that are allowed to ``leak'' from the | |
3765 | daemon's environment to the build environment. This is only applicable | |
3766 | to fixed-output derivations---i.e., when @var{hash} is true. The main | |
3767 | use is to allow variables such as @code{http_proxy} to be passed to | |
3768 | derivations that download files. | |
3769 | ||
1909431c LC |
3770 | When @var{local-build?} is true, declare that the derivation is not a |
3771 | good candidate for offloading and should rather be built locally | |
3772 | (@pxref{Daemon Offload Setup}). This is the case for small derivations | |
3773 | where the costs of data transfers would outweigh the benefits. | |
4a6aeb67 LC |
3774 | |
3775 | When @var{substitutable?} is false, declare that substitutes of the | |
3776 | derivation's output should not be used (@pxref{Substitutes}). This is | |
3777 | useful, for instance, when building packages that capture details of the | |
3778 | host CPU instruction set. | |
874e6874 LC |
3779 | @end deffn |
3780 | ||
3781 | @noindent | |
3782 | Here's an example with a shell script as its builder, assuming | |
3783 | @var{store} is an open connection to the daemon, and @var{bash} points | |
3784 | to a Bash executable in the store: | |
3785 | ||
3786 | @lisp | |
3787 | (use-modules (guix utils) | |
3788 | (guix store) | |
3789 | (guix derivations)) | |
3790 | ||
59688fc4 LC |
3791 | (let ((builder ; add the Bash script to the store |
3792 | (add-text-to-store store "my-builder.sh" | |
3793 | "echo hello world > $out\n" '()))) | |
3794 | (derivation store "foo" | |
3795 | bash `("-e" ,builder) | |
21b679f6 | 3796 | #:inputs `((,bash) (,builder)) |
59688fc4 | 3797 | #:env-vars '(("HOME" . "/homeless")))) |
834129e0 | 3798 | @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo> |
874e6874 LC |
3799 | @end lisp |
3800 | ||
21b679f6 LC |
3801 | As can be guessed, this primitive is cumbersome to use directly. A |
3802 | better approach is to write build scripts in Scheme, of course! The | |
3803 | best course of action for that is to write the build code as a | |
3804 | ``G-expression'', and to pass it to @code{gexp->derivation}. For more | |
6621cdb6 | 3805 | information, @pxref{G-Expressions}. |
21b679f6 | 3806 | |
f2fadbc1 AE |
3807 | Once upon a time, @code{gexp->derivation} did not exist and constructing |
3808 | derivations with build code written in Scheme was achieved with | |
3809 | @code{build-expression->derivation}, documented below. This procedure | |
3810 | is now deprecated in favor of the much nicer @code{gexp->derivation}. | |
3811 | ||
3812 | @deffn {Scheme Procedure} build-expression->derivation @var{store} @ | |
3813 | @var{name} @var{exp} @ | |
3814 | [#:system (%current-system)] [#:inputs '()] @ | |
3815 | [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
3816 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
3817 | [#:references-graphs #f] [#:allowed-references #f] @ | |
35b5ca78 | 3818 | [#:disallowed-references #f] @ |
f2fadbc1 AE |
3819 | [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f] |
3820 | Return a derivation that executes Scheme expression @var{exp} as a | |
3821 | builder for derivation @var{name}. @var{inputs} must be a list of | |
3822 | @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted, | |
3823 | @code{"out"} is assumed. @var{modules} is a list of names of Guile | |
3824 | modules from the current search path to be copied in the store, | |
3825 | compiled, and made available in the load path during the execution of | |
3826 | @var{exp}---e.g., @code{((guix build utils) (guix build | |
3827 | gnu-build-system))}. | |
3828 | ||
3829 | @var{exp} is evaluated in an environment where @code{%outputs} is bound | |
3830 | to a list of output/path pairs, and where @code{%build-inputs} is bound | |
3831 | to a list of string/output-path pairs made from @var{inputs}. | |
3832 | Optionally, @var{env-vars} is a list of string pairs specifying the name | |
3833 | and value of environment variables visible to the builder. The builder | |
3834 | terminates by passing the result of @var{exp} to @code{exit}; thus, when | |
3835 | @var{exp} returns @code{#f}, the build is considered to have failed. | |
3836 | ||
3837 | @var{exp} is built using @var{guile-for-build} (a derivation). When | |
3838 | @var{guile-for-build} is omitted or is @code{#f}, the value of the | |
3839 | @code{%guile-for-build} fluid is used instead. | |
3840 | ||
3841 | See the @code{derivation} procedure for the meaning of | |
35b5ca78 LC |
3842 | @var{references-graphs}, @var{allowed-references}, |
3843 | @var{disallowed-references}, @var{local-build?}, and | |
3844 | @var{substitutable?}. | |
f2fadbc1 AE |
3845 | @end deffn |
3846 | ||
3847 | @noindent | |
3848 | Here's an example of a single-output derivation that creates a directory | |
3849 | containing one file: | |
3850 | ||
3851 | @lisp | |
3852 | (let ((builder '(let ((out (assoc-ref %outputs "out"))) | |
3853 | (mkdir out) ; create /gnu/store/@dots{}-goo | |
3854 | (call-with-output-file (string-append out "/test") | |
3855 | (lambda (p) | |
3856 | (display '(hello guix) p)))))) | |
3857 | (build-expression->derivation store "goo" builder)) | |
3858 | ||
3859 | @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}> | |
3860 | @end lisp | |
3861 | ||
568717fd | 3862 | |
b860f382 LC |
3863 | @node The Store Monad |
3864 | @section The Store Monad | |
3865 | ||
3866 | @cindex monad | |
3867 | ||
3868 | The procedures that operate on the store described in the previous | |
3869 | sections all take an open connection to the build daemon as their first | |
3870 | argument. Although the underlying model is functional, they either have | |
3871 | side effects or depend on the current state of the store. | |
3872 | ||
3873 | The former is inconvenient: the connection to the build daemon has to be | |
3874 | carried around in all those functions, making it impossible to compose | |
3875 | functions that do not take that parameter with functions that do. The | |
3876 | latter can be problematic: since store operations have side effects | |
3877 | and/or depend on external state, they have to be properly sequenced. | |
3878 | ||
3879 | @cindex monadic values | |
3880 | @cindex monadic functions | |
3881 | This is where the @code{(guix monads)} module comes in. This module | |
3882 | provides a framework for working with @dfn{monads}, and a particularly | |
3883 | useful monad for our uses, the @dfn{store monad}. Monads are a | |
3884 | construct that allows two things: associating ``context'' with values | |
3885 | (in our case, the context is the store), and building sequences of | |
4827b36d | 3886 | computations (here computations include accesses to the store). Values |
b860f382 LC |
3887 | in a monad---values that carry this additional context---are called |
3888 | @dfn{monadic values}; procedures that return such values are called | |
3889 | @dfn{monadic procedures}. | |
3890 | ||
3891 | Consider this ``normal'' procedure: | |
3892 | ||
3893 | @example | |
45adbd62 LC |
3894 | (define (sh-symlink store) |
3895 | ;; Return a derivation that symlinks the 'bash' executable. | |
3896 | (let* ((drv (package-derivation store bash)) | |
3897 | (out (derivation->output-path drv)) | |
3898 | (sh (string-append out "/bin/bash"))) | |
3899 | (build-expression->derivation store "sh" | |
3900 | `(symlink ,sh %output)))) | |
b860f382 LC |
3901 | @end example |
3902 | ||
c6f30b81 LC |
3903 | Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten |
3904 | as a monadic function: | |
b860f382 LC |
3905 | |
3906 | @example | |
45adbd62 | 3907 | (define (sh-symlink) |
b860f382 | 3908 | ;; Same, but return a monadic value. |
c6f30b81 LC |
3909 | (mlet %store-monad ((drv (package->derivation bash))) |
3910 | (gexp->derivation "sh" | |
3911 | #~(symlink (string-append #$drv "/bin/bash") | |
3912 | #$output)))) | |
b860f382 LC |
3913 | @end example |
3914 | ||
4827b36d | 3915 | There are several things to note in the second version: the @code{store} |
c6f30b81 LC |
3916 | parameter is now implicit and is ``threaded'' in the calls to the |
3917 | @code{package->derivation} and @code{gexp->derivation} monadic | |
3918 | procedures, and the monadic value returned by @code{package->derivation} | |
3919 | is @dfn{bound} using @code{mlet} instead of plain @code{let}. | |
3920 | ||
3921 | As it turns out, the call to @code{package->derivation} can even be | |
3922 | omitted since it will take place implicitly, as we will see later | |
3923 | (@pxref{G-Expressions}): | |
3924 | ||
3925 | @example | |
3926 | (define (sh-symlink) | |
3927 | (gexp->derivation "sh" | |
3928 | #~(symlink (string-append #$bash "/bin/bash") | |
3929 | #$output))) | |
3930 | @end example | |
b860f382 | 3931 | |
7ce21611 | 3932 | @c See |
a01ad638 | 3933 | @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/> |
7ce21611 LC |
3934 | @c for the funny quote. |
3935 | Calling the monadic @code{sh-symlink} has no effect. As someone once | |
3936 | said, ``you exit a monad like you exit a building on fire: by running''. | |
3937 | So, to exit the monad and get the desired effect, one must use | |
3938 | @code{run-with-store}: | |
b860f382 LC |
3939 | |
3940 | @example | |
8e9aa37f CAW |
3941 | (run-with-store (open-connection) (sh-symlink)) |
3942 | @result{} /gnu/store/...-sh-symlink | |
b860f382 LC |
3943 | @end example |
3944 | ||
f97c9175 | 3945 | Note that the @code{(guix monad-repl)} module extends the Guile REPL with |
b9b86078 | 3946 | new ``meta-commands'' to make it easier to deal with monadic procedures: |
f97c9175 | 3947 | @code{run-in-store}, and @code{enter-store-monad}. The former is used |
b9b86078 LC |
3948 | to ``run'' a single monadic value through the store: |
3949 | ||
3950 | @example | |
3951 | scheme@@(guile-user)> ,run-in-store (package->derivation hello) | |
3952 | $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}> | |
3953 | @end example | |
3954 | ||
3955 | The latter enters a recursive REPL, where all the return values are | |
3956 | automatically run through the store: | |
3957 | ||
3958 | @example | |
3959 | scheme@@(guile-user)> ,enter-store-monad | |
3960 | store-monad@@(guile-user) [1]> (package->derivation hello) | |
3961 | $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}> | |
3962 | store-monad@@(guile-user) [1]> (text-file "foo" "Hello!") | |
3963 | $3 = "/gnu/store/@dots{}-foo" | |
3964 | store-monad@@(guile-user) [1]> ,q | |
3965 | scheme@@(guile-user)> | |
3966 | @end example | |
3967 | ||
3968 | @noindent | |
3969 | Note that non-monadic values cannot be returned in the | |
3970 | @code{store-monad} REPL. | |
3971 | ||
e87f0591 LC |
3972 | The main syntactic forms to deal with monads in general are provided by |
3973 | the @code{(guix monads)} module and are described below. | |
b860f382 LC |
3974 | |
3975 | @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ... | |
3976 | Evaluate any @code{>>=} or @code{return} forms in @var{body} as being | |
3977 | in @var{monad}. | |
3978 | @end deffn | |
3979 | ||
3980 | @deffn {Scheme Syntax} return @var{val} | |
3981 | Return a monadic value that encapsulates @var{val}. | |
3982 | @end deffn | |
3983 | ||
751630c9 | 3984 | @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ... |
b860f382 | 3985 | @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic |
751630c9 LC |
3986 | procedures @var{mproc}@dots{}@footnote{This operation is commonly |
3987 | referred to as ``bind'', but that name denotes an unrelated procedure in | |
3988 | Guile. Thus we use this somewhat cryptic symbol inherited from the | |
3989 | Haskell language.}. There can be one @var{mproc} or several of them, as | |
3990 | in this example: | |
3991 | ||
3992 | @example | |
3993 | (run-with-state | |
3994 | (with-monad %state-monad | |
3995 | (>>= (return 1) | |
3996 | (lambda (x) (return (+ 1 x))) | |
3997 | (lambda (x) (return (* 2 x))))) | |
3998 | 'some-state) | |
3999 | ||
4000 | @result{} 4 | |
4001 | @result{} some-state | |
4002 | @end example | |
b860f382 LC |
4003 | @end deffn |
4004 | ||
4005 | @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @ | |
4006 | @var{body} ... | |
4007 | @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @ | |
4008 | @var{body} ... | |
4009 | Bind the variables @var{var} to the monadic values @var{mval} in | |
4010 | @var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the | |
4011 | ``normal'' value @var{val}, as per @code{let}. | |
4012 | ||
4013 | @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let} | |
4014 | (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}). | |
4015 | @end deffn | |
4016 | ||
405a9d4e LC |
4017 | @deffn {Scheme System} mbegin @var{monad} @var{mexp} ... |
4018 | Bind @var{mexp} and the following monadic expressions in sequence, | |
4019 | returning the result of the last expression. | |
4020 | ||
4021 | This is akin to @code{mlet}, except that the return values of the | |
4022 | monadic expressions are ignored. In that sense, it is analogous to | |
4023 | @code{begin}, but applied to monadic expressions. | |
4024 | @end deffn | |
4025 | ||
561fb6c3 LC |
4026 | @cindex state monad |
4027 | The @code{(guix monads)} module provides the @dfn{state monad}, which | |
4028 | allows an additional value---the state---to be @emph{threaded} through | |
4029 | monadic procedure calls. | |
4030 | ||
4031 | @defvr {Scheme Variable} %state-monad | |
4032 | The state monad. Procedures in the state monad can access and change | |
4033 | the state that is threaded. | |
4034 | ||
4035 | Consider the example below. The @code{square} procedure returns a value | |
4036 | in the state monad. It returns the square of its argument, but also | |
4037 | increments the current state value: | |
4038 | ||
4039 | @example | |
4040 | (define (square x) | |
4041 | (mlet %state-monad ((count (current-state))) | |
4042 | (mbegin %state-monad | |
4043 | (set-current-state (+ 1 count)) | |
4044 | (return (* x x))))) | |
4045 | ||
4046 | (run-with-state (sequence %state-monad (map square (iota 3))) 0) | |
4047 | @result{} (0 1 4) | |
4048 | @result{} 3 | |
4049 | @end example | |
4050 | ||
4051 | When ``run'' through @var{%state-monad}, we obtain that additional state | |
4052 | value, which is the number of @code{square} calls. | |
4053 | @end defvr | |
4054 | ||
4055 | @deffn {Monadic Procedure} current-state | |
4056 | Return the current state as a monadic value. | |
4057 | @end deffn | |
4058 | ||
4059 | @deffn {Monadic Procedure} set-current-state @var{value} | |
4060 | Set the current state to @var{value} and return the previous state as a | |
4061 | monadic value. | |
4062 | @end deffn | |
4063 | ||
4064 | @deffn {Monadic Procedure} state-push @var{value} | |
4065 | Push @var{value} to the current state, which is assumed to be a list, | |
4066 | and return the previous state as a monadic value. | |
4067 | @end deffn | |
4068 | ||
4069 | @deffn {Monadic Procedure} state-pop | |
4070 | Pop a value from the current state and return it as a monadic value. | |
4071 | The state is assumed to be a list. | |
4072 | @end deffn | |
4073 | ||
4074 | @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}] | |
4075 | Run monadic value @var{mval} starting with @var{state} as the initial | |
4076 | state. Return two values: the resulting value, and the resulting state. | |
4077 | @end deffn | |
4078 | ||
e87f0591 LC |
4079 | The main interface to the store monad, provided by the @code{(guix |
4080 | store)} module, is as follows. | |
b860f382 LC |
4081 | |
4082 | @defvr {Scheme Variable} %store-monad | |
561fb6c3 LC |
4083 | The store monad---an alias for @var{%state-monad}. |
4084 | ||
4085 | Values in the store monad encapsulate accesses to the store. When its | |
4086 | effect is needed, a value of the store monad must be ``evaluated'' by | |
4087 | passing it to the @code{run-with-store} procedure (see below.) | |
b860f382 LC |
4088 | @end defvr |
4089 | ||
4090 | @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)] | |
4091 | Run @var{mval}, a monadic value in the store monad, in @var{store}, an | |
4092 | open store connection. | |
4093 | @end deffn | |
4094 | ||
ad372953 | 4095 | @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}] |
b860f382 | 4096 | Return as a monadic value the absolute file name in the store of the file |
ad372953 LC |
4097 | containing @var{text}, a string. @var{references} is a list of store items that the |
4098 | resulting text file refers to; it defaults to the empty list. | |
45adbd62 LC |
4099 | @end deffn |
4100 | ||
0a90af15 | 4101 | @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @ |
1ec32f4a | 4102 | [#:recursive? #t] [#:select? (const #t)] |
0a90af15 LC |
4103 | Return the name of @var{file} once interned in the store. Use |
4104 | @var{name} as its store name, or the basename of @var{file} if | |
4105 | @var{name} is omitted. | |
4106 | ||
4107 | When @var{recursive?} is true, the contents of @var{file} are added | |
4108 | recursively; if @var{file} designates a flat file and @var{recursive?} | |
4109 | is true, its contents are added, and its permission bits are kept. | |
4110 | ||
1ec32f4a LC |
4111 | When @var{recursive?} is true, call @code{(@var{select?} @var{file} |
4112 | @var{stat})} for each directory entry, where @var{file} is the entry's | |
4113 | absolute file name and @var{stat} is the result of @code{lstat}; exclude | |
4114 | entries for which @var{select?} does not return true. | |
4115 | ||
0a90af15 LC |
4116 | The example below adds a file to the store, under two different names: |
4117 | ||
4118 | @example | |
4119 | (run-with-store (open-connection) | |
4120 | (mlet %store-monad ((a (interned-file "README")) | |
4121 | (b (interned-file "README" "LEGU-MIN"))) | |
4122 | (return (list a b)))) | |
4123 | ||
4124 | @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN") | |
4125 | @end example | |
4126 | ||
4127 | @end deffn | |
4128 | ||
e87f0591 LC |
4129 | The @code{(guix packages)} module exports the following package-related |
4130 | monadic procedures: | |
4131 | ||
b860f382 | 4132 | @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @ |
4231f05b | 4133 | [#:system (%current-system)] [#:target #f] @ |
f97c9175 AE |
4134 | [#:output "out"] |
4135 | Return as a monadic | |
b860f382 LC |
4136 | value in the absolute file name of @var{file} within the @var{output} |
4137 | directory of @var{package}. When @var{file} is omitted, return the name | |
4231f05b LC |
4138 | of the @var{output} directory of @var{package}. When @var{target} is |
4139 | true, use it as a cross-compilation target triplet. | |
b860f382 LC |
4140 | @end deffn |
4141 | ||
b860f382 | 4142 | @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}] |
4231f05b LC |
4143 | @deffnx {Monadic Procedure} package->cross-derivation @var{package} @ |
4144 | @var{target} [@var{system}] | |
4145 | Monadic version of @code{package-derivation} and | |
4146 | @code{package-cross-derivation} (@pxref{Defining Packages}). | |
b860f382 LC |
4147 | @end deffn |
4148 | ||
4149 | ||
21b679f6 LC |
4150 | @node G-Expressions |
4151 | @section G-Expressions | |
4152 | ||
4153 | @cindex G-expression | |
4154 | @cindex build code quoting | |
4155 | So we have ``derivations'', which represent a sequence of build actions | |
4156 | to be performed to produce an item in the store (@pxref{Derivations}). | |
f97c9175 | 4157 | These build actions are performed when asking the daemon to actually |
21b679f6 LC |
4158 | build the derivations; they are run by the daemon in a container |
4159 | (@pxref{Invoking guix-daemon}). | |
4160 | ||
4161 | @cindex strata of code | |
f97c9175 | 4162 | It should come as no surprise that we like to write these build actions |
21b679f6 LC |
4163 | in Scheme. When we do that, we end up with two @dfn{strata} of Scheme |
4164 | code@footnote{The term @dfn{stratum} in this context was coined by | |
ef4ab0a4 LC |
4165 | Manuel Serrano et al.@: in the context of their work on Hop. Oleg |
4166 | Kiselyov, who has written insightful | |
4167 | @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code | |
4168 | on this topic}, refers to this kind of code generation as | |
4169 | @dfn{staging}.}: the ``host code''---code that defines packages, talks | |
4170 | to the daemon, etc.---and the ``build code''---code that actually | |
4171 | performs build actions, such as making directories, invoking | |
4172 | @command{make}, etc. | |
21b679f6 LC |
4173 | |
4174 | To describe a derivation and its build actions, one typically needs to | |
4175 | embed build code inside host code. It boils down to manipulating build | |
f97c9175 | 4176 | code as data, and the homoiconicity of Scheme---code has a direct |
21b679f6 | 4177 | representation as data---comes in handy for that. But we need more than |
f97c9175 | 4178 | the normal @code{quasiquote} mechanism in Scheme to construct build |
21b679f6 LC |
4179 | expressions. |
4180 | ||
4181 | The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of | |
4182 | S-expressions adapted to build expressions. G-expressions, or | |
f97c9175 | 4183 | @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp}, |
21b679f6 | 4184 | @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~}, |
f97c9175 AE |
4185 | @code{#$}, and @code{#$@@}), which are comparable to |
4186 | @code{quasiquote}, @code{unquote}, and @code{unquote-splicing}, | |
4827b36d | 4187 | respectively (@pxref{Expression Syntax, @code{quasiquote},, guile, |
f97c9175 | 4188 | GNU Guile Reference Manual}). However, there are major differences: |
21b679f6 LC |
4189 | |
4190 | @itemize | |
4191 | @item | |
4192 | Gexps are meant to be written to a file and run or manipulated by other | |
4193 | processes. | |
4194 | ||
4195 | @item | |
b39fc6f7 LC |
4196 | When a high-level object such as a package or derivation is unquoted |
4197 | inside a gexp, the result is as if its output file name had been | |
4198 | introduced. | |
ff40e9b7 | 4199 | |
21b679f6 LC |
4200 | @item |
4201 | Gexps carry information about the packages or derivations they refer to, | |
4202 | and these dependencies are automatically added as inputs to the build | |
4203 | processes that use them. | |
4204 | @end itemize | |
4205 | ||
c2b84676 | 4206 | @cindex lowering, of high-level objects in gexps |
343eacbe LC |
4207 | This mechanism is not limited to package and derivation |
4208 | objects: @dfn{compilers} able to ``lower'' other high-level objects to | |
c2b84676 LC |
4209 | derivations or files in the store can be defined, |
4210 | such that these objects can also be inserted | |
f97c9175 | 4211 | into gexps. For example, a useful type of high-level objects that can be |
343eacbe | 4212 | inserted in a gexp is ``file-like objects'', which make it easy to |
f97c9175 | 4213 | add files to the store and to refer to them in |
558e8b11 LC |
4214 | derivations and such (see @code{local-file} and @code{plain-file} |
4215 | below.) | |
b39fc6f7 | 4216 | |
21b679f6 LC |
4217 | To illustrate the idea, here is an example of a gexp: |
4218 | ||
4219 | @example | |
4220 | (define build-exp | |
4221 | #~(begin | |
4222 | (mkdir #$output) | |
4223 | (chdir #$output) | |
aff8ce7c | 4224 | (symlink (string-append #$coreutils "/bin/ls") |
21b679f6 LC |
4225 | "list-files"))) |
4226 | @end example | |
4227 | ||
4228 | This gexp can be passed to @code{gexp->derivation}; we obtain a | |
4229 | derivation that builds a directory containing exactly one symlink to | |
4230 | @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}: | |
4231 | ||
4232 | @example | |
4233 | (gexp->derivation "the-thing" build-exp) | |
4234 | @end example | |
4235 | ||
e20fd1bf | 4236 | As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is |
21b679f6 LC |
4237 | substituted to the reference to the @var{coreutils} package in the |
4238 | actual build code, and @var{coreutils} is automatically made an input to | |
4239 | the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp | |
f97c9175 AE |
4240 | output)}) is replaced by a string containing the directory name of the |
4241 | output of the derivation. | |
667b2508 LC |
4242 | |
4243 | @cindex cross compilation | |
4244 | In a cross-compilation context, it is useful to distinguish between | |
4245 | references to the @emph{native} build of a package---that can run on the | |
4246 | host---versus references to cross builds of a package. To that end, the | |
4247 | @code{#+} plays the same role as @code{#$}, but is a reference to a | |
4248 | native package build: | |
4249 | ||
4250 | @example | |
4251 | (gexp->derivation "vi" | |
4252 | #~(begin | |
4253 | (mkdir #$output) | |
4254 | (system* (string-append #+coreutils "/bin/ln") | |
4255 | "-s" | |
4256 | (string-append #$emacs "/bin/emacs") | |
4257 | (string-append #$output "/bin/vi"))) | |
4a3b6aa5 | 4258 | #:target "mips64el-linux-gnu") |
667b2508 LC |
4259 | @end example |
4260 | ||
4261 | @noindent | |
4262 | In the example above, the native build of @var{coreutils} is used, so | |
4263 | that @command{ln} can actually run on the host; but then the | |
4264 | cross-compiled build of @var{emacs} is referenced. | |
4265 | ||
0bb9929e LC |
4266 | @cindex imported modules, for gexps |
4267 | @findex with-imported-modules | |
4268 | Another gexp feature is @dfn{imported modules}: sometimes you want to be | |
4269 | able to use certain Guile modules from the ``host environment'' in the | |
4270 | gexp, so those modules should be imported in the ``build environment''. | |
4271 | The @code{with-imported-modules} form allows you to express that: | |
4272 | ||
4273 | @example | |
4274 | (let ((build (with-imported-modules '((guix build utils)) | |
4275 | #~(begin | |
4276 | (use-modules (guix build utils)) | |
4277 | (mkdir-p (string-append #$output "/bin")))))) | |
4278 | (gexp->derivation "empty-dir" | |
4279 | #~(begin | |
4280 | #$build | |
4281 | (display "success!\n") | |
4282 | #t))) | |
4283 | @end example | |
4284 | ||
4285 | @noindent | |
4286 | In this example, the @code{(guix build utils)} module is automatically | |
4287 | pulled into the isolated build environment of our gexp, such that | |
4288 | @code{(use-modules (guix build utils))} works as expected. | |
4289 | ||
7ca87354 LC |
4290 | @cindex module closure |
4291 | @findex source-module-closure | |
4292 | Usually you want the @emph{closure} of the module to be imported---i.e., | |
4293 | the module itself and all the modules it depends on---rather than just | |
4294 | the module; failing to do that, attempts to use the module will fail | |
4295 | because of missing dependent modules. The @code{source-module-closure} | |
4296 | procedure computes the closure of a module by looking at its source file | |
4297 | headers, which comes in handy in this case: | |
4298 | ||
4299 | @example | |
4300 | (use-modules (guix modules)) ;for 'source-module-closure' | |
4301 | ||
4302 | (with-imported-modules (source-module-closure | |
4303 | '((guix build utils) | |
4304 | (gnu build vm))) | |
4305 | (gexp->derivation "something-with-vms" | |
4306 | #~(begin | |
4307 | (use-modules (guix build utils) | |
4308 | (gnu build vm)) | |
4309 | @dots{}))) | |
4310 | @end example | |
4311 | ||
667b2508 | 4312 | The syntactic form to construct gexps is summarized below. |
21b679f6 LC |
4313 | |
4314 | @deffn {Scheme Syntax} #~@var{exp} | |
4315 | @deffnx {Scheme Syntax} (gexp @var{exp}) | |
4316 | Return a G-expression containing @var{exp}. @var{exp} may contain one | |
4317 | or more of the following forms: | |
4318 | ||
4319 | @table @code | |
4320 | @item #$@var{obj} | |
4321 | @itemx (ungexp @var{obj}) | |
b39fc6f7 LC |
4322 | Introduce a reference to @var{obj}. @var{obj} may have one of the |
4323 | supported types, for example a package or a | |
21b679f6 LC |
4324 | derivation, in which case the @code{ungexp} form is replaced by its |
4325 | output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}. | |
4326 | ||
b39fc6f7 LC |
4327 | If @var{obj} is a list, it is traversed and references to supported |
4328 | objects are substituted similarly. | |
21b679f6 LC |
4329 | |
4330 | If @var{obj} is another gexp, its contents are inserted and its | |
4331 | dependencies are added to those of the containing gexp. | |
4332 | ||
4333 | If @var{obj} is another kind of object, it is inserted as is. | |
4334 | ||
b39fc6f7 LC |
4335 | @item #$@var{obj}:@var{output} |
4336 | @itemx (ungexp @var{obj} @var{output}) | |
21b679f6 | 4337 | This is like the form above, but referring explicitly to the |
b39fc6f7 LC |
4338 | @var{output} of @var{obj}---this is useful when @var{obj} produces |
4339 | multiple outputs (@pxref{Packages with Multiple Outputs}). | |
21b679f6 | 4340 | |
667b2508 LC |
4341 | @item #+@var{obj} |
4342 | @itemx #+@var{obj}:output | |
4343 | @itemx (ungexp-native @var{obj}) | |
4344 | @itemx (ungexp-native @var{obj} @var{output}) | |
4345 | Same as @code{ungexp}, but produces a reference to the @emph{native} | |
4346 | build of @var{obj} when used in a cross compilation context. | |
4347 | ||
21b679f6 LC |
4348 | @item #$output[:@var{output}] |
4349 | @itemx (ungexp output [@var{output}]) | |
4350 | Insert a reference to derivation output @var{output}, or to the main | |
4351 | output when @var{output} is omitted. | |
4352 | ||
4353 | This only makes sense for gexps passed to @code{gexp->derivation}. | |
4354 | ||
4355 | @item #$@@@var{lst} | |
4356 | @itemx (ungexp-splicing @var{lst}) | |
4357 | Like the above, but splices the contents of @var{lst} inside the | |
4358 | containing list. | |
4359 | ||
667b2508 LC |
4360 | @item #+@@@var{lst} |
4361 | @itemx (ungexp-native-splicing @var{lst}) | |
4362 | Like the above, but refers to native builds of the objects listed in | |
4363 | @var{lst}. | |
4364 | ||
21b679f6 LC |
4365 | @end table |
4366 | ||
4367 | G-expressions created by @code{gexp} or @code{#~} are run-time objects | |
4368 | of the @code{gexp?} type (see below.) | |
4369 | @end deffn | |
4370 | ||
0bb9929e LC |
4371 | @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{} |
4372 | Mark the gexps defined in @var{body}@dots{} as requiring @var{modules} | |
d938a58b LC |
4373 | in their execution environment. |
4374 | ||
4375 | Each item in @var{modules} can be the name of a module, such as | |
4376 | @code{(guix build utils)}, or it can be a module name, followed by an | |
4377 | arrow, followed by a file-like object: | |
4378 | ||
4379 | @example | |
4380 | `((guix build utils) | |
4381 | (guix gcrypt) | |
4382 | ((guix config) => ,(scheme-file "config.scm" | |
4383 | #~(define-module @dots{})))) | |
4384 | @end example | |
4385 | ||
4386 | @noindent | |
4387 | In the example above, the first two modules are taken from the search | |
4388 | path, and the last one is created from the given file-like object. | |
0bb9929e LC |
4389 | |
4390 | This form has @emph{lexical} scope: it has an effect on the gexps | |
4391 | directly defined in @var{body}@dots{}, but not on those defined, say, in | |
4392 | procedures called from @var{body}@dots{}. | |
4393 | @end deffn | |
4394 | ||
21b679f6 LC |
4395 | @deffn {Scheme Procedure} gexp? @var{obj} |
4396 | Return @code{#t} if @var{obj} is a G-expression. | |
4397 | @end deffn | |
4398 | ||
4399 | G-expressions are meant to be written to disk, either as code building | |
4400 | some derivation, or as plain files in the store. The monadic procedures | |
4401 | below allow you to do that (@pxref{The Store Monad}, for more | |
4402 | information about monads.) | |
4403 | ||
4404 | @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @ | |
ce45eb4c | 4405 | [#:system (%current-system)] [#:target #f] [#:graft? #t] @ |
21b679f6 LC |
4406 | [#:hash #f] [#:hash-algo #f] @ |
4407 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
4684f301 | 4408 | [#:module-path @var{%load-path}] @ |
c8351d9a | 4409 | [#:references-graphs #f] [#:allowed-references #f] @ |
3f4ecf32 | 4410 | [#:disallowed-references #f] @ |
c0468155 | 4411 | [#:leaked-env-vars #f] @ |
0309e1b0 | 4412 | [#:script-name (string-append @var{name} "-builder")] @ |
4a6aeb67 | 4413 | [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f] |
21b679f6 | 4414 | Return a derivation @var{name} that runs @var{exp} (a gexp) with |
0309e1b0 LC |
4415 | @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is |
4416 | stored in a file called @var{script-name}. When @var{target} is true, | |
4417 | it is used as the cross-compilation target triplet for packages referred | |
4418 | to by @var{exp}. | |
21b679f6 | 4419 | |
0bb9929e LC |
4420 | @var{modules} is deprecated in favor of @code{with-imported-modules}. |
4421 | Its meaning is to | |
4422 | make @var{modules} available in the evaluation context of @var{exp}; | |
ce45eb4c LC |
4423 | @var{modules} is a list of names of Guile modules searched in |
4424 | @var{module-path} to be copied in the store, compiled, and made available in | |
21b679f6 LC |
4425 | the load path during the execution of @var{exp}---e.g., @code{((guix |
4426 | build utils) (guix build gnu-build-system))}. | |
4427 | ||
ce45eb4c LC |
4428 | @var{graft?} determines whether packages referred to by @var{exp} should be grafted when |
4429 | applicable. | |
4430 | ||
b53833b2 LC |
4431 | When @var{references-graphs} is true, it must be a list of tuples of one of the |
4432 | following forms: | |
4433 | ||
4434 | @example | |
4435 | (@var{file-name} @var{package}) | |
4436 | (@var{file-name} @var{package} @var{output}) | |
4437 | (@var{file-name} @var{derivation}) | |
4438 | (@var{file-name} @var{derivation} @var{output}) | |
4439 | (@var{file-name} @var{store-item}) | |
4440 | @end example | |
4441 | ||
4442 | The right-hand-side of each element of @var{references-graphs} is automatically made | |
4443 | an input of the build process of @var{exp}. In the build environment, each | |
4444 | @var{file-name} contains the reference graph of the corresponding item, in a simple | |
4445 | text format. | |
4446 | ||
c8351d9a LC |
4447 | @var{allowed-references} must be either @code{#f} or a list of output names and packages. |
4448 | In the latter case, the list denotes store items that the result is allowed to | |
4449 | refer to. Any reference to another store item will lead to a build error. | |
3f4ecf32 LC |
4450 | Similarly for @var{disallowed-references}, which can list items that must not be |
4451 | referenced by the outputs. | |
c8351d9a | 4452 | |
e20fd1bf | 4453 | The other arguments are as for @code{derivation} (@pxref{Derivations}). |
21b679f6 LC |
4454 | @end deffn |
4455 | ||
343eacbe | 4456 | @cindex file-like objects |
e1c153e0 LC |
4457 | The @code{local-file}, @code{plain-file}, @code{computed-file}, |
4458 | @code{program-file}, and @code{scheme-file} procedures below return | |
4459 | @dfn{file-like objects}. That is, when unquoted in a G-expression, | |
4460 | these objects lead to a file in the store. Consider this G-expression: | |
343eacbe LC |
4461 | |
4462 | @example | |
a9e5e92f | 4463 | #~(system* #$(file-append glibc "/sbin/nscd") "-f" |
343eacbe LC |
4464 | #$(local-file "/tmp/my-nscd.conf")) |
4465 | @end example | |
4466 | ||
4467 | The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it | |
4468 | to the store. Once expanded, for instance @i{via} | |
4469 | @code{gexp->derivation}, the G-expression refers to that copy under | |
4470 | @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp} | |
4471 | does not have any effect on what the G-expression does. | |
4472 | @code{plain-file} can be used similarly; it differs in that the file | |
4473 | content is directly passed as a string. | |
4474 | ||
d9ae938f | 4475 | @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @ |
0687fc9c | 4476 | [#:recursive? #f] [#:select? (const #t)] |
d9ae938f | 4477 | Return an object representing local file @var{file} to add to the store; this |
9d3994f7 LC |
4478 | object can be used in a gexp. If @var{file} is a relative file name, it is looked |
4479 | up relative to the source file where this form appears. @var{file} will be added to | |
4480 | the store under @var{name}--by default the base name of @var{file}. | |
d9ae938f LC |
4481 | |
4482 | When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file} | |
4483 | designates a flat file and @var{recursive?} is true, its contents are added, and its | |
4484 | permission bits are kept. | |
4485 | ||
0687fc9c LC |
4486 | When @var{recursive?} is true, call @code{(@var{select?} @var{file} |
4487 | @var{stat})} for each directory entry, where @var{file} is the entry's | |
4488 | absolute file name and @var{stat} is the result of @code{lstat}; exclude | |
4489 | entries for which @var{select?} does not return true. | |
4490 | ||
d9ae938f LC |
4491 | This is the declarative counterpart of the @code{interned-file} monadic |
4492 | procedure (@pxref{The Store Monad, @code{interned-file}}). | |
4493 | @end deffn | |
4494 | ||
558e8b11 LC |
4495 | @deffn {Scheme Procedure} plain-file @var{name} @var{content} |
4496 | Return an object representing a text file called @var{name} with the given | |
4497 | @var{content} (a string) to be added to the store. | |
4498 | ||
4499 | This is the declarative counterpart of @code{text-file}. | |
4500 | @end deffn | |
4501 | ||
91937029 | 4502 | @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @ |
a769bffb | 4503 | [#:options '(#:local-build? #t)] |
91937029 | 4504 | Return an object representing the store item @var{name}, a file or |
a769bffb | 4505 | directory computed by @var{gexp}. @var{options} |
91937029 LC |
4506 | is a list of additional arguments to pass to @code{gexp->derivation}. |
4507 | ||
4508 | This is the declarative counterpart of @code{gexp->derivation}. | |
4509 | @end deffn | |
4510 | ||
21b679f6 LC |
4511 | @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} |
4512 | Return an executable script @var{name} that runs @var{exp} using | |
9c14a487 | 4513 | @var{guile}, with @var{exp}'s imported modules in its search path. |
21b679f6 LC |
4514 | |
4515 | The example below builds a script that simply invokes the @command{ls} | |
4516 | command: | |
4517 | ||
4518 | @example | |
4519 | (use-modules (guix gexp) (gnu packages base)) | |
4520 | ||
4521 | (gexp->script "list-files" | |
a9e5e92f | 4522 | #~(execl #$(file-append coreutils "/bin/ls") |
21b679f6 LC |
4523 | "ls")) |
4524 | @end example | |
4525 | ||
4526 | When ``running'' it through the store (@pxref{The Store Monad, | |
e20fd1bf | 4527 | @code{run-with-store}}), we obtain a derivation that produces an |
21b679f6 LC |
4528 | executable file @file{/gnu/store/@dots{}-list-files} along these lines: |
4529 | ||
4530 | @example | |
4531 | #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds | |
4532 | !# | |
a9e5e92f | 4533 | (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls") |
21b679f6 LC |
4534 | @end example |
4535 | @end deffn | |
4536 | ||
15a01c72 | 4537 | @deffn {Scheme Procedure} program-file @var{name} @var{exp} @ |
9c14a487 | 4538 | [#:guile #f] |
15a01c72 LC |
4539 | Return an object representing the executable store item @var{name} that |
4540 | runs @var{gexp}. @var{guile} is the Guile package used to execute that | |
9c14a487 | 4541 | script. |
15a01c72 LC |
4542 | |
4543 | This is the declarative counterpart of @code{gexp->script}. | |
4544 | @end deffn | |
4545 | ||
2b418579 LC |
4546 | @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @ |
4547 | [#:set-load-path? #t] | |
21b679f6 | 4548 | Return a derivation that builds a file @var{name} containing @var{exp}. |
2b418579 LC |
4549 | When @var{set-load-path?} is true, emit code in the resulting file to |
4550 | set @code{%load-path} and @code{%load-compiled-path} to honor | |
4551 | @var{exp}'s imported modules. | |
21b679f6 LC |
4552 | |
4553 | The resulting file holds references to all the dependencies of @var{exp} | |
4554 | or a subset thereof. | |
4555 | @end deffn | |
1ed19464 | 4556 | |
e1c153e0 LC |
4557 | @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} |
4558 | Return an object representing the Scheme file @var{name} that contains | |
4559 | @var{exp}. | |
4560 | ||
4561 | This is the declarative counterpart of @code{gexp->file}. | |
4562 | @end deffn | |
4563 | ||
1ed19464 LC |
4564 | @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{} |
4565 | Return as a monadic value a derivation that builds a text file | |
4566 | containing all of @var{text}. @var{text} may list, in addition to | |
d9ae938f LC |
4567 | strings, objects of any type that can be used in a gexp: packages, |
4568 | derivations, local file objects, etc. The resulting store file holds | |
4569 | references to all these. | |
1ed19464 LC |
4570 | |
4571 | This variant should be preferred over @code{text-file} anytime the file | |
4572 | to create will reference items from the store. This is typically the | |
4573 | case when building a configuration file that embeds store file names, | |
4574 | like this: | |
4575 | ||
4576 | @example | |
4577 | (define (profile.sh) | |
4578 | ;; Return the name of a shell script in the store that | |
4579 | ;; initializes the 'PATH' environment variable. | |
4580 | (text-file* "profile.sh" | |
4581 | "export PATH=" coreutils "/bin:" | |
4582 | grep "/bin:" sed "/bin\n")) | |
4583 | @end example | |
4584 | ||
4585 | In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file | |
b7899749 | 4586 | will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby |
1ed19464 LC |
4587 | preventing them from being garbage-collected during its lifetime. |
4588 | @end deffn | |
21b679f6 | 4589 | |
b751cde3 LC |
4590 | @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{} |
4591 | Return an object representing store file @var{name} containing | |
4592 | @var{text}. @var{text} is a sequence of strings and file-like objects, | |
4593 | as in: | |
4594 | ||
4595 | @example | |
4596 | (mixed-text-file "profile" | |
4597 | "export PATH=" coreutils "/bin:" grep "/bin") | |
4598 | @end example | |
4599 | ||
4600 | This is the declarative counterpart of @code{text-file*}. | |
4601 | @end deffn | |
4602 | ||
a9e5e92f LC |
4603 | @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{} |
4604 | Return a file-like object that expands to the concatenation of @var{obj} | |
4605 | and @var{suffix}, where @var{obj} is a lowerable object and each | |
4606 | @var{suffix} is a string. | |
4607 | ||
4608 | As an example, consider this gexp: | |
4609 | ||
4610 | @example | |
4611 | (gexp->script "run-uname" | |
4612 | #~(system* #$(file-append coreutils | |
4613 | "/bin/uname"))) | |
4614 | @end example | |
4615 | ||
4616 | The same effect could be achieved with: | |
4617 | ||
4618 | @example | |
4619 | (gexp->script "run-uname" | |
4620 | #~(system* (string-append #$coreutils | |
4621 | "/bin/uname"))) | |
4622 | @end example | |
4623 | ||
4624 | There is one difference though: in the @code{file-append} case, the | |
4625 | resulting script contains the absolute file name as a string, whereas in | |
4626 | the second case, the resulting script contains a @code{(string-append | |
4627 | @dots{})} expression to construct the file name @emph{at run time}. | |
4628 | @end deffn | |
4629 | ||
4630 | ||
21b679f6 LC |
4631 | Of course, in addition to gexps embedded in ``host'' code, there are |
4632 | also modules containing build tools. To make it clear that they are | |
4633 | meant to be used in the build stratum, these modules are kept in the | |
4634 | @code{(guix build @dots{})} name space. | |
4635 | ||
c2b84676 LC |
4636 | @cindex lowering, of high-level objects in gexps |
4637 | Internally, high-level objects are @dfn{lowered}, using their compiler, | |
4638 | to either derivations or store items. For instance, lowering a package | |
4639 | yields a derivation, and lowering a @code{plain-file} yields a store | |
4640 | item. This is achieved using the @code{lower-object} monadic procedure. | |
4641 | ||
4642 | @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @ | |
4643 | [#:target #f] | |
4644 | Return as a value in @var{%store-monad} the derivation or store item | |
4645 | corresponding to @var{obj} for @var{system}, cross-compiling for | |
4646 | @var{target} if @var{target} is true. @var{obj} must be an object that | |
4647 | has an associated gexp compiler, such as a @code{<package>}. | |
4648 | @end deffn | |
4649 | ||
21b679f6 | 4650 | |
568717fd LC |
4651 | @c ********************************************************************* |
4652 | @node Utilities | |
4653 | @chapter Utilities | |
4654 | ||
6f773606 LC |
4655 | This section describes Guix command-line utilities. Some of them are |
4656 | primarily targeted at developers and users who write new package | |
4657 | definitions, while others are more generally useful. They complement | |
4658 | the Scheme programming interface of Guix in a convenient way. | |
210cc920 | 4659 | |
568717fd | 4660 | @menu |
37166310 | 4661 | * Invoking guix build:: Building packages from the command line. |
39bee8a2 | 4662 | * Invoking guix edit:: Editing package definitions. |
210cc920 | 4663 | * Invoking guix download:: Downloading a file and printing its hash. |
37166310 | 4664 | * Invoking guix hash:: Computing the cryptographic hash of a file. |
2f7d2d91 | 4665 | * Invoking guix import:: Importing package definitions. |
37166310 | 4666 | * Invoking guix refresh:: Updating package definitions. |
b4f5e0e8 | 4667 | * Invoking guix lint:: Finding errors in package definitions. |
fcc58db6 | 4668 | * Invoking guix size:: Profiling disk usage. |
88856916 | 4669 | * Invoking guix graph:: Visualizing the graph of packages. |
372c4bbc | 4670 | * Invoking guix environment:: Setting up development environments. |
aff8ce7c | 4671 | * Invoking guix publish:: Sharing substitutes. |
d23c20f1 | 4672 | * Invoking guix challenge:: Challenging substitute servers. |
f11c444d | 4673 | * Invoking guix copy:: Copying to and from a remote store. |
32efa254 | 4674 | * Invoking guix container:: Process isolation. |
568717fd LC |
4675 | @end menu |
4676 | ||
e49951eb MW |
4677 | @node Invoking guix build |
4678 | @section Invoking @command{guix build} | |
568717fd | 4679 | |
e32171ee JD |
4680 | @cindex package building |
4681 | @cindex @command{guix build} | |
e49951eb | 4682 | The @command{guix build} command builds packages or derivations and |
6798a8e4 LC |
4683 | their dependencies, and prints the resulting store paths. Note that it |
4684 | does not modify the user's profile---this is the job of the | |
e49951eb | 4685 | @command{guix package} command (@pxref{Invoking guix package}). Thus, |
6798a8e4 LC |
4686 | it is mainly useful for distribution developers. |
4687 | ||
4688 | The general syntax is: | |
c78bd12b LC |
4689 | |
4690 | @example | |
e49951eb | 4691 | guix build @var{options} @var{package-or-derivation}@dots{} |
c78bd12b LC |
4692 | @end example |
4693 | ||
f97c9175 | 4694 | As an example, the following command builds the latest versions of Emacs |
ccd7158d LC |
4695 | and of Guile, displays their build logs, and finally displays the |
4696 | resulting directories: | |
4697 | ||
4698 | @example | |
4699 | guix build emacs guile | |
4700 | @end example | |
4701 | ||
4702 | Similarly, the following command builds all the available packages: | |
4703 | ||
4704 | @example | |
5284339d | 4705 | guix build --quiet --keep-going \ |
ccd7158d LC |
4706 | `guix package -A | cut -f1,2 --output-delimiter=@@` |
4707 | @end example | |
4708 | ||
c78bd12b | 4709 | @var{package-or-derivation} may be either the name of a package found in |
5401dd75 | 4710 | the software distribution such as @code{coreutils} or |
e1a65ae5 | 4711 | @code{coreutils@@8.20}, or a derivation such as |
834129e0 | 4712 | @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a |
e7f34eb0 LC |
4713 | package with the corresponding name (and optionally version) is searched |
4714 | for among the GNU distribution modules (@pxref{Package Modules}). | |
4715 | ||
4716 | Alternatively, the @code{--expression} option may be used to specify a | |
4717 | Scheme expression that evaluates to a package; this is useful when | |
b7899749 | 4718 | disambiguating among several same-named packages or package variants is |
e7f34eb0 | 4719 | needed. |
c78bd12b | 4720 | |
ccd7158d LC |
4721 | There may be zero or more @var{options}. The available options are |
4722 | described in the subsections below. | |
4723 | ||
4724 | @menu | |
4725 | * Common Build Options:: Build options for most commands. | |
f11c444d | 4726 | * Package Transformation Options:: Creating variants of packages. |
ccd7158d LC |
4727 | * Additional Build Options:: Options specific to 'guix build'. |
4728 | @end menu | |
4729 | ||
4730 | @node Common Build Options | |
4731 | @subsection Common Build Options | |
4732 | ||
4733 | A number of options that control the build process are common to | |
4734 | @command{guix build} and other commands that can spawn builds, such as | |
4735 | @command{guix package} or @command{guix archive}. These are the | |
4736 | following: | |
4737 | ||
4738 | @table @code | |
4739 | ||
4740 | @item --load-path=@var{directory} | |
4741 | @itemx -L @var{directory} | |
4742 | Add @var{directory} to the front of the package module search path | |
4743 | (@pxref{Package Modules}). | |
4744 | ||
4745 | This allows users to define their own packages and make them visible to | |
4746 | the command-line tools. | |
4747 | ||
4748 | @item --keep-failed | |
4749 | @itemx -K | |
b7899749 | 4750 | Keep the build tree of failed builds. Thus, if a build fails, its build |
ccd7158d LC |
4751 | tree is kept under @file{/tmp}, in a directory whose name is shown at |
4752 | the end of the build log. This is useful when debugging build issues. | |
4753 | ||
4754 | @item --keep-going | |
4755 | @itemx -k | |
4756 | Keep going when some of the derivations fail to build; return only once | |
4757 | all the builds have either completed or failed. | |
4758 | ||
4759 | The default behavior is to stop as soon as one of the specified | |
4760 | derivations has failed. | |
4761 | ||
4762 | @item --dry-run | |
4763 | @itemx -n | |
4764 | Do not build the derivations. | |
4765 | ||
4766 | @item --fallback | |
4767 | When substituting a pre-built binary fails, fall back to building | |
4768 | packages locally. | |
4769 | ||
4770 | @item --substitute-urls=@var{urls} | |
4771 | @anchor{client-substitute-urls} | |
4772 | Consider @var{urls} the whitespace-separated list of substitute source | |
4773 | URLs, overriding the default list of URLs of @command{guix-daemon} | |
4774 | (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}). | |
4775 | ||
4776 | This means that substitutes may be downloaded from @var{urls}, provided | |
4777 | they are signed by a key authorized by the system administrator | |
4778 | (@pxref{Substitutes}). | |
4779 | ||
71e2065a LC |
4780 | When @var{urls} is the empty string, substitutes are effectively |
4781 | disabled. | |
4782 | ||
ccd7158d LC |
4783 | @item --no-substitutes |
4784 | Do not use substitutes for build products. That is, always build things | |
4785 | locally instead of allowing downloads of pre-built binaries | |
4786 | (@pxref{Substitutes}). | |
4787 | ||
7573d30f LC |
4788 | @item --no-grafts |
4789 | Do not ``graft'' packages. In practice, this means that package updates | |
4790 | available as grafts are not applied. @xref{Security Updates}, for more | |
4791 | information on grafts. | |
4792 | ||
ccd7158d LC |
4793 | @item --rounds=@var{n} |
4794 | Build each derivation @var{n} times in a row, and raise an error if | |
4795 | consecutive build results are not bit-for-bit identical. | |
4796 | ||
4797 | This is a useful way to detect non-deterministic builds processes. | |
4798 | Non-deterministic build processes are a problem because they make it | |
4799 | practically impossible for users to @emph{verify} whether third-party | |
4800 | binaries are genuine. @xref{Invoking guix challenge}, for more. | |
4801 | ||
4802 | Note that, currently, the differing build results are not kept around, | |
4803 | so you will have to manually investigate in case of an error---e.g., by | |
e66d1f59 ML |
4804 | stashing one of the build results with @code{guix archive --export} |
4805 | (@pxref{Invoking guix archive}), then rebuilding, and finally comparing | |
4806 | the two results. | |
ccd7158d LC |
4807 | |
4808 | @item --no-build-hook | |
f97c9175 | 4809 | Do not attempt to offload builds @i{via} the ``build hook'' of the daemon |
ccd7158d LC |
4810 | (@pxref{Daemon Offload Setup}). That is, always build things locally |
4811 | instead of offloading builds to remote machines. | |
4812 | ||
4813 | @item --max-silent-time=@var{seconds} | |
4814 | When the build or substitution process remains silent for more than | |
4815 | @var{seconds}, terminate it and report a build failure. | |
4816 | ||
4817 | @item --timeout=@var{seconds} | |
4818 | Likewise, when the build or substitution process lasts for more than | |
4819 | @var{seconds}, terminate it and report a build failure. | |
4820 | ||
4821 | By default there is no timeout. This behavior can be restored with | |
4822 | @code{--timeout=0}. | |
4823 | ||
4824 | @item --verbosity=@var{level} | |
4825 | Use the given verbosity level. @var{level} must be an integer between 0 | |
4826 | and 5; higher means more verbose output. Setting a level of 4 or more | |
4827 | may be helpful when debugging setup issues with the build daemon. | |
4828 | ||
4829 | @item --cores=@var{n} | |
4830 | @itemx -c @var{n} | |
4831 | Allow the use of up to @var{n} CPU cores for the build. The special | |
4832 | value @code{0} means to use as many CPU cores as available. | |
4833 | ||
4834 | @item --max-jobs=@var{n} | |
4835 | @itemx -M @var{n} | |
4836 | Allow at most @var{n} build jobs in parallel. @xref{Invoking | |
4837 | guix-daemon, @code{--max-jobs}}, for details about this option and the | |
4838 | equivalent @command{guix-daemon} option. | |
4839 | ||
4840 | @end table | |
4841 | ||
4842 | Behind the scenes, @command{guix build} is essentially an interface to | |
4843 | the @code{package-derivation} procedure of the @code{(guix packages)} | |
4844 | module, and to the @code{build-derivations} procedure of the @code{(guix | |
4845 | derivations)} module. | |
4846 | ||
4847 | In addition to options explicitly passed on the command line, | |
4848 | @command{guix build} and other @command{guix} commands that support | |
4849 | building honor the @code{GUIX_BUILD_OPTIONS} environment variable. | |
4850 | ||
4851 | @defvr {Environment Variable} GUIX_BUILD_OPTIONS | |
4852 | Users can define this variable to a list of command line options that | |
4853 | will automatically be used by @command{guix build} and other | |
4854 | @command{guix} commands that can perform builds, as in the example | |
4855 | below: | |
4856 | ||
4857 | @example | |
4858 | $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar" | |
4859 | @end example | |
4860 | ||
4861 | These options are parsed independently, and the result is appended to | |
4862 | the parsed command-line options. | |
4863 | @end defvr | |
4864 | ||
88ad6ded LC |
4865 | |
4866 | @node Package Transformation Options | |
4867 | @subsection Package Transformation Options | |
4868 | ||
4869 | @cindex package variants | |
4870 | Another set of command-line options supported by @command{guix build} | |
b8638f03 | 4871 | and also @command{guix package} are @dfn{package transformation |
f97c9175 | 4872 | options}. These are options that make it possible to define @dfn{package |
b8638f03 LC |
4873 | variants}---for instance, packages built from different source code. |
4874 | This is a convenient way to create customized packages on the fly | |
4875 | without having to type in the definitions of package variants | |
4876 | (@pxref{Defining Packages}). | |
88ad6ded LC |
4877 | |
4878 | @table @code | |
4879 | ||
4880 | @item --with-source=@var{source} | |
4881 | Use @var{source} as the source of the corresponding package. | |
4882 | @var{source} must be a file name or a URL, as for @command{guix | |
4883 | download} (@pxref{Invoking guix download}). | |
4884 | ||
f97c9175 AE |
4885 | The ``corresponding package'' is taken to be the one specified on the |
4886 | command line the name of which matches the base of @var{source}---e.g., | |
4887 | if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding | |
88ad6ded | 4888 | package is @code{guile}. Likewise, the version string is inferred from |
f97c9175 | 4889 | @var{source}; in the previous example, it is @code{2.0.10}. |
88ad6ded LC |
4890 | |
4891 | This option allows users to try out versions of packages other than the | |
4892 | one provided by the distribution. The example below downloads | |
4893 | @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for | |
4894 | the @code{ed} package: | |
4895 | ||
4896 | @example | |
4897 | guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz | |
4898 | @end example | |
4899 | ||
4900 | As a developer, @code{--with-source} makes it easy to test release | |
4901 | candidates: | |
4902 | ||
4903 | @example | |
4904 | guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz | |
4905 | @end example | |
4906 | ||
4907 | @dots{} or to build from a checkout in a pristine environment: | |
4908 | ||
4909 | @example | |
4910 | $ git clone git://git.sv.gnu.org/guix.git | |
4911 | $ guix build guix --with-source=./guix | |
4912 | @end example | |
4913 | ||
47c0f92c LC |
4914 | @item --with-input=@var{package}=@var{replacement} |
4915 | Replace dependency on @var{package} by a dependency on | |
4916 | @var{replacement}. @var{package} must be a package name, and | |
4917 | @var{replacement} must be a package specification such as @code{guile} | |
4918 | or @code{guile@@1.8}. | |
4919 | ||
f97c9175 | 4920 | For instance, the following command builds Guix, but replaces its |
47c0f92c LC |
4921 | dependency on the current stable version of Guile with a dependency on |
4922 | the development version of Guile, @code{guile-next}: | |
4923 | ||
4924 | @example | |
4925 | guix build --with-input=guile=guile-next guix | |
4926 | @end example | |
4927 | ||
4928 | This is a recursive, deep replacement. So in this example, both | |
4929 | @code{guix} and its dependency @code{guile-json} (which also depends on | |
4930 | @code{guile}) get rebuilt against @code{guile-next}. | |
4931 | ||
2a75b0b6 LC |
4932 | This is implemented using the @code{package-input-rewriting} Scheme |
4933 | procedure (@pxref{Defining Packages, @code{package-input-rewriting}}). | |
645b9df8 LC |
4934 | |
4935 | @item --with-graft=@var{package}=@var{replacement} | |
4936 | This is similar to @code{--with-input} but with an important difference: | |
9b4ec573 | 4937 | instead of rebuilding the whole dependency chain, @var{replacement} is |
645b9df8 LC |
4938 | built and then @dfn{grafted} onto the binaries that were initially |
4939 | referring to @var{package}. @xref{Security Updates}, for more | |
4940 | information on grafts. | |
4941 | ||
4942 | For example, the command below grafts version 3.5.4 of GnuTLS onto Wget | |
4943 | and all its dependencies, replacing references to the version of GnuTLS | |
4944 | they currently refer to: | |
4945 | ||
4946 | @example | |
4947 | guix build --with-graft=gnutls=gnutls@@3.5.4 wget | |
4948 | @end example | |
4949 | ||
4950 | This has the advantage of being much faster than rebuilding everything. | |
4951 | But there is a caveat: it works if and only if @var{package} and | |
4952 | @var{replacement} are strictly compatible---for example, if they provide | |
4953 | a library, the application binary interface (ABI) of those libraries | |
4954 | must be compatible. If @var{replacement} is somehow incompatible with | |
4955 | @var{package}, then the resulting package may be unusable. Use with | |
4956 | care! | |
4957 | ||
88ad6ded LC |
4958 | @end table |
4959 | ||
ccd7158d LC |
4960 | @node Additional Build Options |
4961 | @subsection Additional Build Options | |
4962 | ||
4963 | The command-line options presented below are specific to @command{guix | |
4964 | build}. | |
c78bd12b LC |
4965 | |
4966 | @table @code | |
4967 | ||
5284339d LC |
4968 | @item --quiet |
4969 | @itemx -q | |
4970 | Build quietly, without displaying the build log. Upon completion, the | |
4971 | build log is kept in @file{/var} (or similar) and can always be | |
4972 | retrieved using the @option{--log-file} option. | |
4973 | ||
34a1783f DT |
4974 | @item --file=@var{file} |
4975 | @itemx -f @var{file} | |
4976 | ||
4977 | Build the package or derivation that the code within @var{file} | |
4978 | evaluates to. | |
4979 | ||
4980 | As an example, @var{file} might contain a package definition like this | |
4981 | (@pxref{Defining Packages}): | |
4982 | ||
4983 | @example | |
4984 | @verbatiminclude package-hello.scm | |
4985 | @end example | |
4986 | ||
c78bd12b LC |
4987 | @item --expression=@var{expr} |
4988 | @itemx -e @var{expr} | |
ac5de156 | 4989 | Build the package or derivation @var{expr} evaluates to. |
c78bd12b | 4990 | |
5401dd75 | 4991 | For example, @var{expr} may be @code{(@@ (gnu packages guile) |
c78bd12b LC |
4992 | guile-1.8)}, which unambiguously designates this specific variant of |
4993 | version 1.8 of Guile. | |
4994 | ||
f97c9175 | 4995 | Alternatively, @var{expr} may be a G-expression, in which case it is used |
56b82106 LC |
4996 | as a build program passed to @code{gexp->derivation} |
4997 | (@pxref{G-Expressions}). | |
4998 | ||
4999 | Lastly, @var{expr} may refer to a zero-argument monadic procedure | |
ac5de156 LC |
5000 | (@pxref{The Store Monad}). The procedure must return a derivation as a |
5001 | monadic value, which is then passed through @code{run-with-store}. | |
5002 | ||
c78bd12b LC |
5003 | @item --source |
5004 | @itemx -S | |
f97c9175 | 5005 | Build the source derivations of the packages, rather than the packages |
c78bd12b LC |
5006 | themselves. |
5007 | ||
e49951eb | 5008 | For instance, @code{guix build -S gcc} returns something like |
f97c9175 AE |
5009 | @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC |
5010 | source tarball. | |
c78bd12b | 5011 | |
f9cc8971 | 5012 | The returned source tarball is the result of applying any patches and |
f97c9175 | 5013 | code snippets specified in the package @code{origin} (@pxref{Defining |
f9cc8971 LC |
5014 | Packages}). |
5015 | ||
2cdfe13d EB |
5016 | @item --sources |
5017 | Fetch and return the source of @var{package-or-derivation} and all their | |
5018 | dependencies, recursively. This is a handy way to obtain a local copy | |
5019 | of all the source code needed to build @var{packages}, allowing you to | |
5020 | eventually build them even without network access. It is an extension | |
5021 | of the @code{--source} option and can accept one of the following | |
5022 | optional argument values: | |
5023 | ||
5024 | @table @code | |
5025 | @item package | |
5026 | This value causes the @code{--sources} option to behave in the same way | |
5027 | as the @code{--source} option. | |
5028 | ||
5029 | @item all | |
f97c9175 AE |
5030 | Build the source derivations of all packages, including any source that |
5031 | might be listed as @code{inputs}. This is the default value. | |
2cdfe13d EB |
5032 | |
5033 | @example | |
5034 | $ guix build --sources tzdata | |
5035 | The following derivations will be built: | |
5036 | /gnu/store/@dots{}-tzdata2015b.tar.gz.drv | |
5037 | /gnu/store/@dots{}-tzcode2015b.tar.gz.drv | |
5038 | @end example | |
5039 | ||
5040 | @item transitive | |
f97c9175 AE |
5041 | Build the source derivations of all packages, as well of all transitive |
5042 | inputs to the packages. This can be used e.g. to | |
2cdfe13d EB |
5043 | prefetch package source for later offline building. |
5044 | ||
5045 | @example | |
5046 | $ guix build --sources=transitive tzdata | |
5047 | The following derivations will be built: | |
5048 | /gnu/store/@dots{}-tzcode2015b.tar.gz.drv | |
5049 | /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv | |
5050 | /gnu/store/@dots{}-grep-2.21.tar.xz.drv | |
5051 | /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv | |
5052 | /gnu/store/@dots{}-make-4.1.tar.xz.drv | |
5053 | /gnu/store/@dots{}-bash-4.3.tar.xz.drv | |
5054 | @dots{} | |
5055 | @end example | |
5056 | ||
5057 | @end table | |
5058 | ||
c78bd12b LC |
5059 | @item --system=@var{system} |
5060 | @itemx -s @var{system} | |
5061 | Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of | |
f97c9175 | 5062 | the system type of the build host. |
c78bd12b LC |
5063 | |
5064 | An example use of this is on Linux-based systems, which can emulate | |
5065 | different personalities. For instance, passing | |
5066 | @code{--system=i686-linux} on an @code{x86_64-linux} system allows users | |
5067 | to build packages in a complete 32-bit environment. | |
5068 | ||
e55ec43d LC |
5069 | @item --target=@var{triplet} |
5070 | @cindex cross-compilation | |
5071 | Cross-build for @var{triplet}, which must be a valid GNU triplet, such | |
5461115e LC |
5072 | as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU |
5073 | configuration triplets,, autoconf, Autoconf}). | |
e55ec43d | 5074 | |
a8d65643 LC |
5075 | @anchor{build-check} |
5076 | @item --check | |
5077 | @cindex determinism, checking | |
5078 | @cindex reproducibility, checking | |
5079 | Rebuild @var{package-or-derivation}, which are already available in the | |
5080 | store, and raise an error if the build results are not bit-for-bit | |
5081 | identical. | |
5082 | ||
f97c9175 AE |
5083 | This mechanism allows you to check whether previously installed |
5084 | substitutes are genuine (@pxref{Substitutes}), or whether the build result | |
5085 | of a package is deterministic. @xref{Invoking guix challenge}, for more | |
a8d65643 LC |
5086 | background information and tools. |
5087 | ||
7f3b2510 ED |
5088 | When used in conjunction with @option{--keep-failed}, the differing |
5089 | output is kept in the store, under @file{/gnu/store/@dots{}-check}. | |
5090 | This makes it easy to look for differences between the two results. | |
5091 | ||
6da5bb7b LC |
5092 | @item --repair |
5093 | @cindex repairing store items | |
5094 | @cindex corruption, recovering from | |
5095 | Attempt to repair the specified store items, if they are corrupt, by | |
5096 | re-downloading or rebuilding them. | |
5097 | ||
5098 | This operation is not atomic and thus restricted to @code{root}. | |
5099 | ||
c78bd12b LC |
5100 | @item --derivations |
5101 | @itemx -d | |
5102 | Return the derivation paths, not the output paths, of the given | |
5103 | packages. | |
5104 | ||
70ee5642 LC |
5105 | @item --root=@var{file} |
5106 | @itemx -r @var{file} | |
5107 | Make @var{file} a symlink to the result, and register it as a garbage | |
5108 | collector root. | |
5109 | ||
5110 | @item --log-file | |
3f208ad7 | 5111 | Return the build log file names or URLs for the given |
f97c9175 | 5112 | @var{package-or-derivation}, or raise an error if build logs are |
70ee5642 LC |
5113 | missing. |
5114 | ||
5115 | This works regardless of how packages or derivations are specified. For | |
5116 | instance, the following invocations are equivalent: | |
5117 | ||
5118 | @example | |
5119 | guix build --log-file `guix build -d guile` | |
5120 | guix build --log-file `guix build guile` | |
5121 | guix build --log-file guile | |
5122 | guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)' | |
5123 | @end example | |
5124 | ||
3f208ad7 LC |
5125 | If a log is unavailable locally, and unless @code{--no-substitutes} is |
5126 | passed, the command looks for a corresponding log on one of the | |
5127 | substitute servers (as specified with @code{--substitute-urls}.) | |
70ee5642 | 5128 | |
f97c9175 AE |
5129 | So for instance, imagine you want to see the build log of GDB on MIPS, |
5130 | but you are actually on an @code{x86_64} machine: | |
3f208ad7 LC |
5131 | |
5132 | @example | |
a01ad638 | 5133 | $ guix build --log-file gdb -s mips64el-linux |
df061d07 | 5134 | https://hydra.gnu.org/log/@dots{}-gdb-7.10 |
3f208ad7 LC |
5135 | @end example |
5136 | ||
5137 | You can freely access a huge library of build logs! | |
70ee5642 LC |
5138 | @end table |
5139 | ||
16eb115e | 5140 | |
39bee8a2 LC |
5141 | @node Invoking guix edit |
5142 | @section Invoking @command{guix edit} | |
5143 | ||
e32171ee | 5144 | @cindex @command{guix edit} |
39bee8a2 LC |
5145 | @cindex package definition, editing |
5146 | So many packages, so many source files! The @command{guix edit} command | |
424a323e GC |
5147 | facilitates the life of users and packagers by pointing their editor at |
5148 | the source file containing the definition of the specified packages. | |
5149 | For instance: | |
39bee8a2 LC |
5150 | |
5151 | @example | |
7b9a66e5 | 5152 | guix edit gcc@@4.9 vim |
39bee8a2 LC |
5153 | @end example |
5154 | ||
5155 | @noindent | |
6237b9fa | 5156 | launches the program specified in the @code{VISUAL} or in the |
424a323e | 5157 | @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3 |
6237b9fa | 5158 | and that of Vim. |
39bee8a2 | 5159 | |
424a323e GC |
5160 | If you are using a Guix Git checkout (@pxref{Building from Git}), or |
5161 | have created your own packages on @code{GUIX_PACKAGE_PATH} | |
5162 | (@pxref{Defining Packages}), you will be able to edit the package | |
5163 | recipes. Otherwise, you will be able to examine the read-only recipes | |
5164 | for packages currently in the store. | |
5165 | ||
39bee8a2 | 5166 | |
210cc920 LC |
5167 | @node Invoking guix download |
5168 | @section Invoking @command{guix download} | |
5169 | ||
e32171ee JD |
5170 | @cindex @command{guix download} |
5171 | @cindex downloading package sources | |
210cc920 | 5172 | When writing a package definition, developers typically need to download |
f97c9175 | 5173 | a source tarball, compute its SHA256 hash, and write that |
210cc920 LC |
5174 | hash in the package definition (@pxref{Defining Packages}). The |
5175 | @command{guix download} tool helps with this task: it downloads a file | |
5176 | from the given URI, adds it to the store, and prints both its file name | |
5177 | in the store and its SHA256 hash. | |
5178 | ||
5179 | The fact that the downloaded file is added to the store saves bandwidth: | |
5180 | when the developer eventually tries to build the newly defined package | |
5181 | with @command{guix build}, the source tarball will not have to be | |
5182 | downloaded again because it is already in the store. It is also a | |
5183 | convenient way to temporarily stash files, which may be deleted | |
5184 | eventually (@pxref{Invoking guix gc}). | |
5185 | ||
5186 | The @command{guix download} command supports the same URIs as used in | |
5187 | package definitions. In particular, it supports @code{mirror://} URIs. | |
5188 | @code{https} URIs (HTTP over TLS) are supported @emph{provided} the | |
5189 | Guile bindings for GnuTLS are available in the user's environment; when | |
537c8bb3 LC |
5190 | they are not available, an error is raised. @xref{Guile Preparations, |
5191 | how to install the GnuTLS bindings for Guile,, gnutls-guile, | |
5192 | GnuTLS-Guile}, for more information. | |
210cc920 | 5193 | |
bc3c41ce LC |
5194 | @command{guix download} verifies HTTPS server certificates by loading |
5195 | the certificates of X.509 authorities from the directory pointed to by | |
5196 | the @code{SSL_CERT_DIR} environment variable (@pxref{X.509 | |
64b8695c | 5197 | Certificates}), unless @option{--no-check-certificate} is used. |
bc3c41ce | 5198 | |
64b8695c | 5199 | The following options are available: |
210cc920 LC |
5200 | |
5201 | @table @code | |
5202 | @item --format=@var{fmt} | |
5203 | @itemx -f @var{fmt} | |
5204 | Write the hash in the format specified by @var{fmt}. For more | |
081145cf | 5205 | information on the valid values for @var{fmt}, @pxref{Invoking guix hash}. |
64b8695c LC |
5206 | |
5207 | @item --no-check-certificate | |
5208 | Do not validate the X.509 certificates of HTTPS servers. | |
5209 | ||
5210 | When using this option, you have @emph{absolutely no guarantee} that you | |
5211 | are communicating with the authentic server responsible for the given | |
5212 | URL, which makes you vulnerable to ``man-in-the-middle'' attacks. | |
5213 | ||
1bcc87bb LC |
5214 | @item --output=@var{file} |
5215 | @itemx -o @var{file} | |
5216 | Save the downloaded file to @var{file} instead of adding it to the | |
5217 | store. | |
210cc920 LC |
5218 | @end table |
5219 | ||
6c365eca NK |
5220 | @node Invoking guix hash |
5221 | @section Invoking @command{guix hash} | |
5222 | ||
e32171ee | 5223 | @cindex @command{guix hash} |
210cc920 | 5224 | The @command{guix hash} command computes the SHA256 hash of a file. |
6c365eca NK |
5225 | It is primarily a convenience tool for anyone contributing to the |
5226 | distribution: it computes the cryptographic hash of a file, which can be | |
5227 | used in the definition of a package (@pxref{Defining Packages}). | |
5228 | ||
5229 | The general syntax is: | |
5230 | ||
5231 | @example | |
5232 | guix hash @var{option} @var{file} | |
5233 | @end example | |
5234 | ||
343dc117 LC |
5235 | When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the |
5236 | hash of data read from standard input. @command{guix hash} has the | |
5237 | following options: | |
6c365eca NK |
5238 | |
5239 | @table @code | |
5240 | ||
5241 | @item --format=@var{fmt} | |
5242 | @itemx -f @var{fmt} | |
210cc920 | 5243 | Write the hash in the format specified by @var{fmt}. |
6c365eca NK |
5244 | |
5245 | Supported formats: @code{nix-base32}, @code{base32}, @code{base16} | |
5246 | (@code{hex} and @code{hexadecimal} can be used as well). | |
5247 | ||
5248 | If the @option{--format} option is not specified, @command{guix hash} | |
5249 | will output the hash in @code{nix-base32}. This representation is used | |
5250 | in the definitions of packages. | |
5251 | ||
3140f2df LC |
5252 | @item --recursive |
5253 | @itemx -r | |
5254 | Compute the hash on @var{file} recursively. | |
5255 | ||
5256 | In this case, the hash is computed on an archive containing @var{file}, | |
f97c9175 AE |
5257 | including its children if it is a directory. Some of the metadata of |
5258 | @var{file} is part of the archive; for instance, when @var{file} is a | |
3140f2df | 5259 | regular file, the hash is different depending on whether @var{file} is |
f97c9175 | 5260 | executable or not. Metadata such as time stamps has no impact on the |
3140f2df LC |
5261 | hash (@pxref{Invoking guix archive}). |
5262 | @c FIXME: Replace xref above with xref to an ``Archive'' section when | |
5263 | @c it exists. | |
5264 | ||
392a4e12 JN |
5265 | @item --exclude-vcs |
5266 | @itemx -x | |
5267 | When combined with @option{--recursive}, exclude version control system | |
5268 | directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.) | |
5269 | ||
db97a03a LC |
5270 | @vindex git-fetch |
5271 | As an example, here is how you would compute the hash of a Git checkout, | |
5272 | which is useful when using the @code{git-fetch} method (@pxref{origin | |
5273 | Reference}): | |
5274 | ||
5275 | @example | |
5276 | $ git clone http://example.org/foo.git | |
5277 | $ cd foo | |
392a4e12 | 5278 | $ guix hash -rx . |
db97a03a | 5279 | @end example |
6c365eca NK |
5280 | @end table |
5281 | ||
2f7d2d91 LC |
5282 | @node Invoking guix import |
5283 | @section Invoking @command{guix import} | |
5284 | ||
5285 | @cindex importing packages | |
5286 | @cindex package import | |
5287 | @cindex package conversion | |
e32171ee | 5288 | @cindex Invoking @command{guix import} |
f97c9175 AE |
5289 | The @command{guix import} command is useful for people who would like to |
5290 | add a package to the distribution with as little work as | |
5291 | possible---a legitimate demand. The command knows of a few | |
5292 | repositories from which it can ``import'' package metadata. The result | |
2f7d2d91 LC |
5293 | is a package definition, or a template thereof, in the format we know |
5294 | (@pxref{Defining Packages}). | |
5295 | ||
5296 | The general syntax is: | |
5297 | ||
5298 | @example | |
5299 | guix import @var{importer} @var{options}@dots{} | |
5300 | @end example | |
5301 | ||
5302 | @var{importer} specifies the source from which to import package | |
f97c9175 | 5303 | metadata, and @var{options} specifies a package identifier and other |
2f7d2d91 LC |
5304 | options specific to @var{importer}. Currently, the available |
5305 | ``importers'' are: | |
5306 | ||
5307 | @table @code | |
5308 | @item gnu | |
f97c9175 | 5309 | Import metadata for the given GNU package. This provides a template |
2f7d2d91 LC |
5310 | for the latest version of that GNU package, including the hash of its |
5311 | source tarball, and its canonical synopsis and description. | |
5312 | ||
f97c9175 | 5313 | Additional information such as the package dependencies and its |
2f7d2d91 LC |
5314 | license needs to be figured out manually. |
5315 | ||
5316 | For example, the following command returns a package definition for | |
5317 | GNU@tie{}Hello: | |
5318 | ||
5319 | @example | |
5320 | guix import gnu hello | |
5321 | @end example | |
5322 | ||
5323 | Specific command-line options are: | |
5324 | ||
5325 | @table @code | |
5326 | @item --key-download=@var{policy} | |
5327 | As for @code{guix refresh}, specify the policy to handle missing OpenPGP | |
f97c9175 | 5328 | keys when verifying the package signature. @xref{Invoking guix |
2f7d2d91 LC |
5329 | refresh, @code{--key-download}}. |
5330 | @end table | |
5331 | ||
5332 | @item pypi | |
5333 | @cindex pypi | |
f97c9175 | 5334 | Import metadata from the @uref{https://pypi.python.org/, Python Package |
2f7d2d91 LC |
5335 | Index}@footnote{This functionality requires Guile-JSON to be installed. |
5336 | @xref{Requirements}.}. Information is taken from the JSON-formatted | |
5337 | description available at @code{pypi.python.org} and usually includes all | |
266785d2 CR |
5338 | the relevant information, including package dependencies. For maximum |
5339 | efficiency, it is recommended to install the @command{unzip} utility, so | |
5340 | that the importer can unzip Python wheels and gather data from them. | |
2f7d2d91 | 5341 | |
f97c9175 | 5342 | The command below imports metadata for the @code{itsdangerous} Python |
2f7d2d91 LC |
5343 | package: |
5344 | ||
5345 | @example | |
5346 | guix import pypi itsdangerous | |
5347 | @end example | |
5348 | ||
3aae8145 DT |
5349 | @item gem |
5350 | @cindex gem | |
f97c9175 | 5351 | Import metadata from @uref{https://rubygems.org/, |
3aae8145 DT |
5352 | RubyGems}@footnote{This functionality requires Guile-JSON to be |
5353 | installed. @xref{Requirements}.}. Information is taken from the | |
5354 | JSON-formatted description available at @code{rubygems.org} and includes | |
5355 | most relevant information, including runtime dependencies. There are | |
f97c9175 | 5356 | some caveats, however. The metadata doesn't distinguish between |
3aae8145 DT |
5357 | synopses and descriptions, so the same string is used for both fields. |
5358 | Additionally, the details of non-Ruby dependencies required to build | |
5359 | native extensions is unavailable and left as an exercise to the | |
5360 | packager. | |
5361 | ||
f97c9175 | 5362 | The command below imports metadata for the @code{rails} Ruby package: |
3aae8145 DT |
5363 | |
5364 | @example | |
5365 | guix import gem rails | |
5366 | @end example | |
5367 | ||
d45dc6da EB |
5368 | @item cpan |
5369 | @cindex CPAN | |
3c192e4e AE |
5370 | Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}@footnote{This |
5371 | functionality requires Guile-JSON to be installed. | |
5372 | @xref{Requirements}.}. | |
f97c9175 | 5373 | Information is taken from the JSON-formatted metadata provided through |
d45dc6da | 5374 | @uref{https://api.metacpan.org/, MetaCPAN's API} and includes most |
66392e47 EB |
5375 | relevant information, such as module dependencies. License information |
5376 | should be checked closely. If Perl is available in the store, then the | |
5377 | @code{corelist} utility will be used to filter core modules out of the | |
5378 | list of dependencies. | |
d45dc6da | 5379 | |
f97c9175 | 5380 | The command command below imports metadata for the @code{Acme::Boolean} |
d45dc6da EB |
5381 | Perl module: |
5382 | ||
5383 | @example | |
5384 | guix import cpan Acme::Boolean | |
5385 | @end example | |
5386 | ||
e1248602 RW |
5387 | @item cran |
5388 | @cindex CRAN | |
d0bd632f | 5389 | @cindex Bioconductor |
f97c9175 | 5390 | Import metadata from @uref{http://cran.r-project.org/, CRAN}, the |
e1248602 RW |
5391 | central repository for the @uref{http://r-project.org, GNU@tie{}R |
5392 | statistical and graphical environment}. | |
5393 | ||
f97c9175 | 5394 | Information is extracted from the @code{DESCRIPTION} file of the package. |
e1248602 | 5395 | |
f97c9175 | 5396 | The command command below imports metadata for the @code{Cairo} |
e1248602 RW |
5397 | R package: |
5398 | ||
5399 | @example | |
5400 | guix import cran Cairo | |
5401 | @end example | |
5402 | ||
64ce53eb RW |
5403 | When @code{--recursive} is added, the importer will traverse the |
5404 | dependency graph of the given upstream package recursively and generate | |
5405 | package expressions for all those packages that are not yet in Guix. | |
5406 | ||
f97c9175 | 5407 | When @code{--archive=bioconductor} is added, metadata is imported from |
d0bd632f RW |
5408 | @uref{http://www.bioconductor.org/, Bioconductor}, a repository of R |
5409 | packages for for the analysis and comprehension of high-throughput | |
5410 | genomic data in bioinformatics. | |
5411 | ||
f97c9175 | 5412 | Information is extracted from the @code{DESCRIPTION} file of a package |
d0bd632f RW |
5413 | published on the web interface of the Bioconductor SVN repository. |
5414 | ||
f97c9175 | 5415 | The command below imports metadata for the @code{GenomicRanges} |
d0bd632f RW |
5416 | R package: |
5417 | ||
5418 | @example | |
5419 | guix import cran --archive=bioconductor GenomicRanges | |
5420 | @end example | |
5421 | ||
2f7d2d91 | 5422 | @item nix |
f97c9175 | 5423 | Import metadata from a local copy of the source of the |
2f7d2d91 LC |
5424 | @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This |
5425 | relies on the @command{nix-instantiate} command of | |
5426 | @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are | |
5427 | typically written in a mixture of Nix-language and Bash code. This | |
5428 | command only imports the high-level package structure that is written in | |
5429 | the Nix language. It normally includes all the basic fields of a | |
5430 | package definition. | |
5431 | ||
5432 | When importing a GNU package, the synopsis and descriptions are replaced | |
5433 | by their canonical upstream variant. | |
5434 | ||
961d0d2d LC |
5435 | Usually, you will first need to do: |
5436 | ||
5437 | @example | |
5438 | export NIX_REMOTE=daemon | |
5439 | @end example | |
5440 | ||
5441 | @noindent | |
5442 | so that @command{nix-instantiate} does not try to open the Nix database. | |
5443 | ||
2f7d2d91 LC |
5444 | As an example, the command below imports the package definition of |
5445 | LibreOffice (more precisely, it imports the definition of the package | |
5446 | bound to the @code{libreoffice} top-level attribute): | |
5447 | ||
5448 | @example | |
5449 | guix import nix ~/path/to/nixpkgs libreoffice | |
5450 | @end example | |
863af4e1 FB |
5451 | |
5452 | @item hackage | |
5453 | @cindex hackage | |
f97c9175 | 5454 | Import metadata from the Haskell community's central package archive |
863af4e1 FB |
5455 | @uref{https://hackage.haskell.org/, Hackage}. Information is taken from |
5456 | Cabal files and includes all the relevant information, including package | |
5457 | dependencies. | |
5458 | ||
5459 | Specific command-line options are: | |
5460 | ||
5461 | @table @code | |
a4154748 FB |
5462 | @item --stdin |
5463 | @itemx -s | |
f97c9175 | 5464 | Read a Cabal file from standard input. |
863af4e1 FB |
5465 | @item --no-test-dependencies |
5466 | @itemx -t | |
f97c9175 | 5467 | Do not include dependencies required only by the test suites. |
a4154748 FB |
5468 | @item --cabal-environment=@var{alist} |
5469 | @itemx -e @var{alist} | |
5470 | @var{alist} is a Scheme alist defining the environment in which the | |
5471 | Cabal conditionals are evaluated. The accepted keys are: @code{os}, | |
5472 | @code{arch}, @code{impl} and a string representing the name of a flag. | |
5473 | The value associated with a flag has to be either the symbol | |
5474 | @code{true} or @code{false}. The value associated with other keys | |
5475 | has to conform to the Cabal file format definition. The default value | |
5476 | associated with the keys @code{os}, @code{arch} and @code{impl} is | |
f97c9175 | 5477 | @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively. |
863af4e1 FB |
5478 | @end table |
5479 | ||
f97c9175 | 5480 | The command below imports metadata for the latest version of the |
a4154748 FB |
5481 | @code{HTTP} Haskell package without including test dependencies and |
5482 | specifying the value of the flag @samp{network-uri} as @code{false}: | |
863af4e1 FB |
5483 | |
5484 | @example | |
a4154748 | 5485 | guix import hackage -t -e "'((\"network-uri\" . false))" HTTP |
863af4e1 FB |
5486 | @end example |
5487 | ||
5488 | A specific package version may optionally be specified by following the | |
1b846da8 | 5489 | package name by an at-sign and a version number as in the following example: |
863af4e1 FB |
5490 | |
5491 | @example | |
1b846da8 | 5492 | guix import hackage mtl@@2.1.3.1 |
863af4e1 | 5493 | @end example |
7f74a931 | 5494 | |
bc5844d1 FB |
5495 | @item stackage |
5496 | @cindex stackage | |
5497 | The @code{stackage} importer is a wrapper around the @code{hackage} one. | |
5498 | It takes a package name, looks up the package version included in a | |
5499 | long-term support (LTS) @uref{https://www.stackage.org, Stackage} | |
5500 | release and uses the @code{hackage} importer to retrieve its metadata. | |
5501 | Note that it is up to you to select an LTS release compatible with the | |
5502 | GHC compiler used by Guix. | |
5503 | ||
5504 | Specific command-line options are: | |
5505 | ||
5506 | @table @code | |
5507 | @item --no-test-dependencies | |
5508 | @itemx -t | |
5509 | Do not include dependencies required only by the test suites. | |
5510 | @item --lts-version=@var{version} | |
5511 | @itemx -r @var{version} | |
5512 | @var{version} is the desired LTS release version. If omitted the latest | |
5513 | release is used. | |
5514 | @end table | |
5515 | ||
5516 | The command below imports metadata for the @code{HTTP} Haskell package | |
5517 | included in the LTS Stackage release version 7.18: | |
5518 | ||
5519 | @example | |
5520 | guix import stackage --lts-version=7.18 HTTP | |
5521 | @end example | |
5522 | ||
7f74a931 FB |
5523 | @item elpa |
5524 | @cindex elpa | |
f97c9175 | 5525 | Import metadata from an Emacs Lisp Package Archive (ELPA) package |
7f74a931 FB |
5526 | repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}). |
5527 | ||
5528 | Specific command-line options are: | |
5529 | ||
5530 | @table @code | |
5531 | @item --archive=@var{repo} | |
5532 | @itemx -a @var{repo} | |
5533 | @var{repo} identifies the archive repository from which to retrieve the | |
5534 | information. Currently the supported repositories and their identifiers | |
5535 | are: | |
5536 | @itemize - | |
5537 | @item | |
840bd1d3 | 5538 | @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu} |
7f74a931 FB |
5539 | identifier. This is the default. |
5540 | ||
624144e0 LC |
5541 | Packages from @code{elpa.gnu.org} are signed with one of the keys |
5542 | contained in the GnuPG keyring at | |
5543 | @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the | |
5544 | @code{emacs} package (@pxref{Package Installation, ELPA package | |
5545 | signatures,, emacs, The GNU Emacs Manual}). | |
5546 | ||
7f74a931 | 5547 | @item |
840bd1d3 | 5548 | @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the |
7f74a931 FB |
5549 | @code{melpa-stable} identifier. |
5550 | ||
5551 | @item | |
840bd1d3 | 5552 | @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa} |
7f74a931 FB |
5553 | identifier. |
5554 | @end itemize | |
5555 | @end table | |
3e0c0365 DC |
5556 | |
5557 | @item crate | |
5558 | @cindex crate | |
5559 | Import metadata from the crates.io Rust package repository | |
5560 | @uref{https://crates.io, crates.io}. | |
2f7d2d91 LC |
5561 | @end table |
5562 | ||
5563 | The structure of the @command{guix import} code is modular. It would be | |
5564 | useful to have more importers for other package formats, and your help | |
5565 | is welcome here (@pxref{Contributing}). | |
5566 | ||
37166310 LC |
5567 | @node Invoking guix refresh |
5568 | @section Invoking @command{guix refresh} | |
5569 | ||
e32171ee | 5570 | @cindex @command {guix refresh} |
37166310 LC |
5571 | The primary audience of the @command{guix refresh} command is developers |
5572 | of the GNU software distribution. By default, it reports any packages | |
5573 | provided by the distribution that are outdated compared to the latest | |
5574 | upstream version, like this: | |
5575 | ||
5576 | @example | |
5577 | $ guix refresh | |
5578 | gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1 | |
5579 | gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0 | |
5580 | @end example | |
5581 | ||
e9c72306 LC |
5582 | Alternately, one can specify packages to consider, in which case a |
5583 | warning is emitted for packages that lack an updater: | |
5584 | ||
5585 | @example | |
5586 | $ guix refresh coreutils guile guile-ssh | |
5587 | gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh | |
5588 | gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13 | |
5589 | @end example | |
5590 | ||
5591 | @command{guix refresh} browses the upstream repository of each package and determines | |
5592 | the highest version number of the releases therein. The command | |
bcb571cb | 5593 | knows how to update specific types of packages: GNU packages, ELPA |
e9c72306 | 5594 | packages, etc.---see the documentation for @option{--type} below. There |
bcb571cb LC |
5595 | are many packages, though, for which it lacks a method to determine |
5596 | whether a new upstream release is available. However, the mechanism is | |
5597 | extensible, so feel free to get in touch with us to add a new method! | |
37166310 LC |
5598 | |
5599 | When passed @code{--update}, it modifies distribution source files to | |
f97c9175 | 5600 | update the version numbers and source tarball hashes of those package |
37166310 LC |
5601 | recipes (@pxref{Defining Packages}). This is achieved by downloading |
5602 | each package's latest source tarball and its associated OpenPGP | |
5603 | signature, authenticating the downloaded tarball against its signature | |
5604 | using @command{gpg}, and finally computing its hash. When the public | |
5605 | key used to sign the tarball is missing from the user's keyring, an | |
5606 | attempt is made to automatically retrieve it from a public key server; | |
f97c9175 | 5607 | when this is successful, the key is added to the user's keyring; otherwise, |
37166310 LC |
5608 | @command{guix refresh} reports an error. |
5609 | ||
5610 | The following options are supported: | |
5611 | ||
5612 | @table @code | |
5613 | ||
2d7fc7da LC |
5614 | @item --expression=@var{expr} |
5615 | @itemx -e @var{expr} | |
5616 | Consider the package @var{expr} evaluates to. | |
5617 | ||
5618 | This is useful to precisely refer to a package, as in this example: | |
5619 | ||
5620 | @example | |
5621 | guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)' | |
5622 | @end example | |
5623 | ||
5624 | This command lists the dependents of the ``final'' libc (essentially all | |
5625 | the packages.) | |
5626 | ||
37166310 LC |
5627 | @item --update |
5628 | @itemx -u | |
38e16b49 LC |
5629 | Update distribution source files (package recipes) in place. This is |
5630 | usually run from a checkout of the Guix source tree (@pxref{Running | |
5631 | Guix Before It Is Installed}): | |
5632 | ||
5633 | @example | |
e9c72306 | 5634 | $ ./pre-inst-env guix refresh -s non-core -u |
38e16b49 LC |
5635 | @end example |
5636 | ||
081145cf | 5637 | @xref{Defining Packages}, for more information on package definitions. |
37166310 LC |
5638 | |
5639 | @item --select=[@var{subset}] | |
5640 | @itemx -s @var{subset} | |
5641 | Select all the packages in @var{subset}, one of @code{core} or | |
5642 | @code{non-core}. | |
5643 | ||
5644 | The @code{core} subset refers to all the packages at the core of the | |
5645 | distribution---i.e., packages that are used to build ``everything | |
5646 | else''. This includes GCC, libc, Binutils, Bash, etc. Usually, | |
5647 | changing one of these packages in the distribution entails a rebuild of | |
5648 | all the others. Thus, such updates are an inconvenience to users in | |
5649 | terms of build time or bandwidth used to achieve the upgrade. | |
5650 | ||
5651 | The @code{non-core} subset refers to the remaining packages. It is | |
5652 | typically useful in cases where an update of the core packages would be | |
5653 | inconvenient. | |
5654 | ||
bcb571cb LC |
5655 | @item --type=@var{updater} |
5656 | @itemx -t @var{updater} | |
7191adc5 AK |
5657 | Select only packages handled by @var{updater} (may be a comma-separated |
5658 | list of updaters). Currently, @var{updater} may be one of: | |
bcb571cb LC |
5659 | |
5660 | @table @code | |
5661 | @item gnu | |
5662 | the updater for GNU packages; | |
e80c0f85 LC |
5663 | @item gnome |
5664 | the updater for GNOME packages; | |
9c97afe8 DC |
5665 | @item kde |
5666 | the updater for KDE packages; | |
62061d6b AW |
5667 | @item xorg |
5668 | the updater for X.org packages; | |
2fd370e8 LC |
5669 | @item kernel.org |
5670 | the updater for packages hosted on kernel.org; | |
bcb571cb | 5671 | @item elpa |
d882c235 LC |
5672 | the updater for @uref{http://elpa.gnu.org/, ELPA} packages; |
5673 | @item cran | |
b9d044ef | 5674 | the updater for @uref{http://cran.r-project.org/, CRAN} packages; |
d0bd632f RW |
5675 | @item bioconductor |
5676 | the updater for @uref{http://www.bioconductor.org/, Bioconductor} R packages; | |
200cdf81 EB |
5677 | @item cpan |
5678 | the updater for @uref{http://www.cpan.org/, CPAN} packages; | |
bab020d7 | 5679 | @item pypi |
b9d044ef | 5680 | the updater for @uref{https://pypi.python.org, PyPI} packages. |
fbc5b815 BW |
5681 | @item gem |
5682 | the updater for @uref{https://rubygems.org, RubyGems} packages. | |
917a2a58 BW |
5683 | @item github |
5684 | the updater for @uref{https://github.com, GitHub} packages. | |
42efe27a EB |
5685 | @item hackage |
5686 | the updater for @uref{https://hackage.haskell.org, Hackage} packages. | |
bc5844d1 FB |
5687 | @item stackage |
5688 | the updater for @uref{https://www.stackage.org, Stackage} packages. | |
8ac52987 DC |
5689 | @item crate |
5690 | the updater for @uref{https://crates.io, Crates} packages. | |
bcb571cb LC |
5691 | @end table |
5692 | ||
f97c9175 AE |
5693 | For instance, the following command only checks for updates of Emacs |
5694 | packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages: | |
bcb571cb LC |
5695 | |
5696 | @example | |
7191adc5 | 5697 | $ guix refresh --type=elpa,cran |
d882c235 | 5698 | gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0 |
bcb571cb LC |
5699 | gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9 |
5700 | @end example | |
5701 | ||
37166310 LC |
5702 | @end table |
5703 | ||
5704 | In addition, @command{guix refresh} can be passed one or more package | |
5705 | names, as in this example: | |
5706 | ||
5707 | @example | |
e9c72306 | 5708 | $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8 |
37166310 LC |
5709 | @end example |
5710 | ||
5711 | @noindent | |
5712 | The command above specifically updates the @code{emacs} and | |
5713 | @code{idutils} packages. The @code{--select} option would have no | |
5714 | effect in this case. | |
5715 | ||
7d193ec3 EB |
5716 | When considering whether to upgrade a package, it is sometimes |
5717 | convenient to know which packages would be affected by the upgrade and | |
5718 | should be checked for compatibility. For this the following option may | |
5719 | be used when passing @command{guix refresh} one or more package names: | |
5720 | ||
5721 | @table @code | |
5722 | ||
6ffa706b AK |
5723 | @item --list-updaters |
5724 | @itemx -L | |
5725 | List available updaters and exit (see @option{--type} above.) | |
5726 | ||
3676f892 LC |
5727 | For each updater, display the fraction of packages it covers; at the |
5728 | end, display the fraction of packages covered by all these updaters. | |
5729 | ||
7d193ec3 EB |
5730 | @item --list-dependent |
5731 | @itemx -l | |
5732 | List top-level dependent packages that would need to be rebuilt as a | |
5733 | result of upgrading one or more packages. | |
5734 | ||
b96a0640 LC |
5735 | @xref{Invoking guix graph, the @code{reverse-package} type of |
5736 | @command{guix graph}}, for information on how to visualize the list of | |
5737 | dependents of a package. | |
5738 | ||
7d193ec3 EB |
5739 | @end table |
5740 | ||
5741 | Be aware that the @code{--list-dependent} option only | |
5742 | @emph{approximates} the rebuilds that would be required as a result of | |
5743 | an upgrade. More rebuilds might be required under some circumstances. | |
5744 | ||
5745 | @example | |
7779ab61 LC |
5746 | $ guix refresh --list-dependent flex |
5747 | Building the following 120 packages would ensure 213 dependent packages are rebuilt: | |
5748 | hop-2.4.0 geiser-0.4 notmuch-0.18 mu-0.9.9.5 cflow-1.4 idutils-4.6 @dots{} | |
7d193ec3 EB |
5749 | @end example |
5750 | ||
5751 | The command above lists a set of packages that could be built to check | |
5752 | for compatibility with an upgraded @code{flex} package. | |
5753 | ||
f9230085 LC |
5754 | The following options can be used to customize GnuPG operation: |
5755 | ||
5756 | @table @code | |
5757 | ||
f9230085 LC |
5758 | @item --gpg=@var{command} |
5759 | Use @var{command} as the GnuPG 2.x command. @var{command} is searched | |
5760 | for in @code{$PATH}. | |
5761 | ||
2bc53ba9 LC |
5762 | @item --key-download=@var{policy} |
5763 | Handle missing OpenPGP keys according to @var{policy}, which may be one | |
5764 | of: | |
5765 | ||
5766 | @table @code | |
5767 | @item always | |
5768 | Always download missing OpenPGP keys from the key server, and add them | |
5769 | to the user's GnuPG keyring. | |
5770 | ||
5771 | @item never | |
5772 | Never try to download missing OpenPGP keys. Instead just bail out. | |
5773 | ||
5774 | @item interactive | |
5775 | When a package signed with an unknown OpenPGP key is encountered, ask | |
5776 | the user whether to download it or not. This is the default behavior. | |
5777 | @end table | |
5778 | ||
5779 | @item --key-server=@var{host} | |
5780 | Use @var{host} as the OpenPGP key server when importing a public key. | |
5781 | ||
f9230085 LC |
5782 | @end table |
5783 | ||
917a2a58 BW |
5784 | The @code{github} updater uses the |
5785 | @uref{https://developer.github.com/v3/, GitHub API} to query for new | |
5786 | releases. When used repeatedly e.g. when refreshing all packages, | |
5787 | GitHub will eventually refuse to answer any further API requests. By | |
5788 | default 60 API requests per hour are allowed, and a full refresh on all | |
5789 | GitHub packages in Guix requires more than this. Authentication with | |
5790 | GitHub through the use of an API token alleviates these limits. To use | |
5791 | an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a | |
5792 | token procured from @uref{https://github.com/settings/tokens} or | |
5793 | otherwise. | |
5794 | ||
5795 | ||
b4f5e0e8 CR |
5796 | @node Invoking guix lint |
5797 | @section Invoking @command{guix lint} | |
e32171ee JD |
5798 | |
5799 | @cindex @command{guix lint} | |
5800 | @cindex package, checking for errors | |
f97c9175 AE |
5801 | The @command{guix lint} command is meant to help package developers avoid |
5802 | common errors and use a consistent style. It runs a number of checks on | |
5803 | a given set of packages in order to find common mistakes in their | |
873c4085 LC |
5804 | definitions. Available @dfn{checkers} include (see |
5805 | @code{--list-checkers} for a complete list): | |
5806 | ||
5807 | @table @code | |
5808 | @item synopsis | |
5809 | @itemx description | |
5810 | Validate certain typographical and stylistic rules about package | |
5811 | descriptions and synopses. | |
5812 | ||
5813 | @item inputs-should-be-native | |
5814 | Identify inputs that should most likely be native inputs. | |
5815 | ||
5816 | @item source | |
5817 | @itemx home-page | |
fac46e3f | 5818 | @itemx mirror-url |
50f5c46d | 5819 | @itemx source-file-name |
873c4085 | 5820 | Probe @code{home-page} and @code{source} URLs and report those that are |
fac46e3f LC |
5821 | invalid. Suggest a @code{mirror://} URL when applicable. Check that |
5822 | the source file name is meaningful, e.g. is not | |
f97c9175 AE |
5823 | just a version number or ``git-checkout'', without a declared |
5824 | @code{file-name} (@pxref{origin Reference}). | |
40a7d4e5 | 5825 | |
5432734b | 5826 | @item cve |
09866b39 LC |
5827 | @cindex security vulnerabilities |
5828 | @cindex CVE, Common Vulnerabilities and Exposures | |
5432734b | 5829 | Report known vulnerabilities found in the Common Vulnerabilities and |
09866b39 | 5830 | Exposures (CVE) databases of the current and past year |
5432734b LC |
5831 | @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US |
5832 | NIST}. | |
5833 | ||
09866b39 LC |
5834 | To view information about a particular vulnerability, visit pages such as: |
5835 | ||
5836 | @itemize | |
5837 | @item | |
5838 | @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD} | |
5839 | @item | |
5840 | @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD} | |
5841 | @end itemize | |
5842 | ||
5843 | @noindent | |
5844 | where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g., | |
5845 | @code{CVE-2015-7554}. | |
5846 | ||
99effc8f LC |
5847 | Package developers can specify in package recipes the |
5848 | @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)} | |
5849 | name and version of the package when they differ from the name that Guix | |
5850 | uses, as in this example: | |
5851 | ||
5852 | @example | |
5853 | (package | |
5854 | (name "grub") | |
5855 | ;; @dots{} | |
5856 | ;; CPE calls this package "grub2". | |
5857 | (properties '((cpe-name . "grub2")))) | |
5858 | @end example | |
5859 | ||
40a7d4e5 LC |
5860 | @item formatting |
5861 | Warn about obvious source code formatting issues: trailing white space, | |
5862 | use of tabulations, etc. | |
873c4085 | 5863 | @end table |
b4f5e0e8 CR |
5864 | |
5865 | The general syntax is: | |
5866 | ||
5867 | @example | |
5868 | guix lint @var{options} @var{package}@dots{} | |
5869 | @end example | |
5870 | ||
5871 | If no package is given on the command line, then all packages are checked. | |
5872 | The @var{options} may be zero or more of the following: | |
5873 | ||
5874 | @table @code | |
f97c9175 AE |
5875 | @item --list-checkers |
5876 | @itemx -l | |
5877 | List and describe all the available checkers that will be run on packages | |
5878 | and exit. | |
b4f5e0e8 | 5879 | |
dd7c013d CR |
5880 | @item --checkers |
5881 | @itemx -c | |
5882 | Only enable the checkers specified in a comma-separated list using the | |
5883 | names returned by @code{--list-checkers}. | |
5884 | ||
b4f5e0e8 | 5885 | @end table |
37166310 | 5886 | |
fcc58db6 LC |
5887 | @node Invoking guix size |
5888 | @section Invoking @command{guix size} | |
5889 | ||
e32171ee JD |
5890 | @cindex size |
5891 | @cindex package size | |
5892 | @cindex closure | |
5893 | @cindex @command{guix size} | |
fcc58db6 LC |
5894 | The @command{guix size} command helps package developers profile the |
5895 | disk usage of packages. It is easy to overlook the impact of an | |
5896 | additional dependency added to a package, or the impact of using a | |
5897 | single output for a package that could easily be split (@pxref{Packages | |
f97c9175 | 5898 | with Multiple Outputs}). Such are the typical issues that |
fcc58db6 LC |
5899 | @command{guix size} can highlight. |
5900 | ||
e1a65ae5 | 5901 | The command can be passed a package specification such as @code{gcc@@4.8} |
fcc58db6 LC |
5902 | or @code{guile:debug}, or a file name in the store. Consider this |
5903 | example: | |
5904 | ||
5905 | @example | |
5906 | $ guix size coreutils | |
5907 | store item total self | |
5908 | /gnu/store/@dots{}-coreutils-8.23 70.0 13.9 19.8% | |
5909 | /gnu/store/@dots{}-gmp-6.0.0a 55.3 2.5 3.6% | |
5910 | /gnu/store/@dots{}-acl-2.2.52 53.7 0.5 0.7% | |
5911 | /gnu/store/@dots{}-attr-2.4.46 53.2 0.3 0.5% | |
5912 | /gnu/store/@dots{}-gcc-4.8.4-lib 52.9 15.7 22.4% | |
5913 | /gnu/store/@dots{}-glibc-2.21 37.2 37.2 53.1% | |
5914 | @end example | |
5915 | ||
5916 | @cindex closure | |
5917 | The store items listed here constitute the @dfn{transitive closure} of | |
5918 | Coreutils---i.e., Coreutils and all its dependencies, recursively---as | |
5919 | would be returned by: | |
5920 | ||
5921 | @example | |
5922 | $ guix gc -R /gnu/store/@dots{}-coreutils-8.23 | |
5923 | @end example | |
5924 | ||
f97c9175 | 5925 | Here the output shows three columns next to store items. The first column, |
fcc58db6 LC |
5926 | labeled ``total'', shows the size in mebibytes (MiB) of the closure of |
5927 | the store item---that is, its own size plus the size of all its | |
5928 | dependencies. The next column, labeled ``self'', shows the size of the | |
f97c9175 AE |
5929 | item itself. The last column shows the ratio of the size of the item |
5930 | itself to the space occupied by all the items listed here. | |
fcc58db6 LC |
5931 | |
5932 | In this example, we see that the closure of Coreutils weighs in at | |
5933 | 70@tie{}MiB, half of which is taken by libc. (That libc represents a | |
5934 | large fraction of the closure is not a problem @i{per se} because it is | |
5935 | always available on the system anyway.) | |
5936 | ||
5937 | When the package passed to @command{guix size} is available in the | |
5938 | store, @command{guix size} queries the daemon to determine its | |
5939 | dependencies, and measures its size in the store, similar to @command{du | |
5940 | -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU | |
5941 | Coreutils}). | |
5942 | ||
5943 | When the given package is @emph{not} in the store, @command{guix size} | |
f97c9175 AE |
5944 | reports information based on the available substitutes |
5945 | (@pxref{Substitutes}). This makes it possible it to profile disk usage of | |
5946 | store items that are not even on disk, only available remotely. | |
fcc58db6 | 5947 | |
db761534 LC |
5948 | You can also specify several package names: |
5949 | ||
5950 | @example | |
5951 | $ guix size coreutils grep sed bash | |
5952 | store item total self | |
5953 | /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4% | |
5954 | /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8% | |
5955 | /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6% | |
5956 | /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2% | |
5957 | @dots{} | |
5958 | total: 102.3 MiB | |
5959 | @end example | |
5960 | ||
5961 | @noindent | |
5962 | In this example we see that the combination of the four packages takes | |
5963 | 102.3@tie{}MiB in total, which is much less than the sum of each closure | |
5964 | since they have a lot of dependencies in common. | |
5965 | ||
a8f996c6 | 5966 | The available options are: |
fcc58db6 LC |
5967 | |
5968 | @table @option | |
5969 | ||
d490d06e LC |
5970 | @item --substitute-urls=@var{urls} |
5971 | Use substitute information from @var{urls}. | |
5972 | @xref{client-substitute-urls, the same option for @code{guix build}}. | |
5973 | ||
a8f996c6 | 5974 | @item --map-file=@var{file} |
f97c9175 | 5975 | Write a graphical map of disk usage in PNG format to @var{file}. |
a8f996c6 LC |
5976 | |
5977 | For the example above, the map looks like this: | |
5978 | ||
5979 | @image{images/coreutils-size-map,5in,, map of Coreutils disk usage | |
5980 | produced by @command{guix size}} | |
5981 | ||
5982 | This option requires that | |
5983 | @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be | |
5984 | installed and visible in Guile's module search path. When that is not | |
5985 | the case, @command{guix size} fails as it tries to load it. | |
5986 | ||
fcc58db6 LC |
5987 | @item --system=@var{system} |
5988 | @itemx -s @var{system} | |
5989 | Consider packages for @var{system}---e.g., @code{x86_64-linux}. | |
5990 | ||
5991 | @end table | |
5992 | ||
88856916 LC |
5993 | @node Invoking guix graph |
5994 | @section Invoking @command{guix graph} | |
5995 | ||
5996 | @cindex DAG | |
e32171ee JD |
5997 | @cindex @command{guix graph} |
5998 | @cindex package dependencies | |
88856916 LC |
5999 | Packages and their dependencies form a @dfn{graph}, specifically a |
6000 | directed acyclic graph (DAG). It can quickly become difficult to have a | |
f97c9175 | 6001 | mental model of the package DAG, so the @command{guix graph} command |
9ea36197 LC |
6002 | provides a visual representation of the DAG. By default, |
6003 | @command{guix graph} emits a DAG representation in the input format of | |
88856916 | 6004 | @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed |
9ea36197 LC |
6005 | directly to the @command{dot} command of Graphviz. It can also emit an |
6006 | HTML page with embedded JavaScript code to display a ``chord diagram'' | |
6007 | in a Web browser, using the @uref{https://d3js.org/, d3.js} library. | |
6008 | The general syntax is: | |
88856916 LC |
6009 | |
6010 | @example | |
6011 | guix graph @var{options} @var{package}@dots{} | |
6012 | @end example | |
6013 | ||
6014 | For example, the following command generates a PDF file representing the | |
6015 | package DAG for the GNU@tie{}Core Utilities, showing its build-time | |
6016 | dependencies: | |
6017 | ||
6018 | @example | |
6019 | guix graph coreutils | dot -Tpdf > dag.pdf | |
6020 | @end example | |
6021 | ||
6022 | The output looks like this: | |
6023 | ||
6024 | @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils} | |
6025 | ||
6026 | Nice little graph, no? | |
6027 | ||
f97c9175 | 6028 | But there is more than one graph! The one above is concise: it is the |
88856916 | 6029 | graph of package objects, omitting implicit inputs such as GCC, libc, |
f97c9175 AE |
6030 | grep, etc. It is often useful to have such a concise graph, but |
6031 | sometimes one may want to see more details. @command{guix graph} supports | |
6032 | several types of graphs, allowing you to choose the level of detail: | |
88856916 LC |
6033 | |
6034 | @table @code | |
6035 | @item package | |
f97c9175 | 6036 | This is the default type used in the example above. It shows the DAG of |
88856916 LC |
6037 | package objects, excluding implicit dependencies. It is concise, but |
6038 | filters out many details. | |
6039 | ||
b96a0640 LC |
6040 | @item reverse-package |
6041 | This shows the @emph{reverse} DAG of packages. For example: | |
6042 | ||
6043 | @example | |
6044 | guix graph --type=reverse-package ocaml | |
6045 | @end example | |
6046 | ||
6047 | ... yields the graph of packages that depend on OCaml. | |
6048 | ||
6049 | Note that for core packages this can yield huge graphs. If all you want | |
6050 | is to know the number of packages that depend on a given package, use | |
6051 | @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh, | |
6052 | @option{--list-dependent}}). | |
6053 | ||
88856916 LC |
6054 | @item bag-emerged |
6055 | This is the package DAG, @emph{including} implicit inputs. | |
6056 | ||
6057 | For instance, the following command: | |
6058 | ||
6059 | @example | |
6060 | guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf | |
6061 | @end example | |
6062 | ||
6063 | ... yields this bigger graph: | |
6064 | ||
6065 | @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils} | |
6066 | ||
6067 | At the bottom of the graph, we see all the implicit inputs of | |
6068 | @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}). | |
6069 | ||
f97c9175 | 6070 | Now, note that the dependencies of these implicit inputs---that is, the |
88856916 LC |
6071 | @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown |
6072 | here, for conciseness. | |
6073 | ||
6074 | @item bag | |
6075 | Similar to @code{bag-emerged}, but this time including all the bootstrap | |
6076 | dependencies. | |
6077 | ||
38b92daa LC |
6078 | @item bag-with-origins |
6079 | Similar to @code{bag}, but also showing origins and their dependencies. | |
6080 | ||
88856916 LC |
6081 | @item derivations |
6082 | This is the most detailed representation: It shows the DAG of | |
6083 | derivations (@pxref{Derivations}) and plain store items. Compared to | |
6084 | the above representation, many additional nodes are visible, including | |
f97c9175 | 6085 | build scripts, patches, Guile modules, etc. |
88856916 | 6086 | |
a773c314 LC |
6087 | For this type of graph, it is also possible to pass a @file{.drv} file |
6088 | name instead of a package name, as in: | |
6089 | ||
6090 | @example | |
6091 | guix graph -t derivation `guix system build -d my-config.scm` | |
6092 | @end example | |
88856916 LC |
6093 | @end table |
6094 | ||
f97c9175 | 6095 | All the types above correspond to @emph{build-time dependencies}. The |
88856916 LC |
6096 | following graph type represents the @emph{run-time dependencies}: |
6097 | ||
6098 | @table @code | |
6099 | @item references | |
6100 | This is the graph of @dfn{references} of a package output, as returned | |
6101 | by @command{guix gc --references} (@pxref{Invoking guix gc}). | |
6102 | ||
6103 | If the given package output is not available in the store, @command{guix | |
6104 | graph} attempts to obtain dependency information from substitutes. | |
a773c314 LC |
6105 | |
6106 | Here you can also pass a store file name instead of a package name. For | |
6107 | example, the command below produces the reference graph of your profile | |
6108 | (which can be big!): | |
6109 | ||
6110 | @example | |
6111 | guix graph -t references `readlink -f ~/.guix-profile` | |
6112 | @end example | |
7f8fec0f LC |
6113 | |
6114 | @item referrers | |
6115 | This is the graph of the @dfn{referrers} of a store item, as returned by | |
6116 | @command{guix gc --referrers} (@pxref{Invoking guix gc}). | |
6117 | ||
6118 | This relies exclusively on local information from your store. For | |
6119 | instance, let us suppose that the current Inkscape is available in 10 | |
6120 | profiles on your machine; @command{guix graph -t referrers inkscape} | |
6121 | will show a graph rooted at Inkscape and with those 10 profiles linked | |
6122 | to it. | |
6123 | ||
6124 | It can help determine what is preventing a store item from being garbage | |
6125 | collected. | |
6126 | ||
88856916 LC |
6127 | @end table |
6128 | ||
6129 | The available options are the following: | |
6130 | ||
6131 | @table @option | |
6132 | @item --type=@var{type} | |
6133 | @itemx -t @var{type} | |
6134 | Produce a graph output of @var{type}, where @var{type} must be one of | |
6135 | the values listed above. | |
6136 | ||
6137 | @item --list-types | |
6138 | List the supported graph types. | |
4c8f997a | 6139 | |
642339dc RW |
6140 | @item --backend=@var{backend} |
6141 | @itemx -b @var{backend} | |
6142 | Produce a graph using the selected @var{backend}. | |
6143 | ||
6144 | @item --list-backends | |
6145 | List the supported graph backends. | |
6146 | ||
9ea36197 LC |
6147 | Currently, the available backends are Graphviz and d3.js. |
6148 | ||
4c8f997a LC |
6149 | @item --expression=@var{expr} |
6150 | @itemx -e @var{expr} | |
6151 | Consider the package @var{expr} evaluates to. | |
6152 | ||
6153 | This is useful to precisely refer to a package, as in this example: | |
6154 | ||
6155 | @example | |
6156 | guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)' | |
6157 | @end example | |
88856916 LC |
6158 | @end table |
6159 | ||
6160 | ||
372c4bbc DT |
6161 | @node Invoking guix environment |
6162 | @section Invoking @command{guix environment} | |
6163 | ||
f5fd4fd2 | 6164 | @cindex reproducible build environments |
fe36d84e | 6165 | @cindex development environments |
e32171ee JD |
6166 | @cindex @command{guix environment} |
6167 | @cindex environment, package build environment | |
372c4bbc DT |
6168 | The purpose of @command{guix environment} is to assist hackers in |
6169 | creating reproducible development environments without polluting their | |
6170 | package profile. The @command{guix environment} tool takes one or more | |
f97c9175 | 6171 | packages, builds all of their inputs, and creates a shell |
372c4bbc DT |
6172 | environment to use them. |
6173 | ||
6174 | The general syntax is: | |
6175 | ||
6176 | @example | |
6177 | guix environment @var{options} @var{package}@dots{} | |
6178 | @end example | |
6179 | ||
fe36d84e LC |
6180 | The following example spawns a new shell set up for the development of |
6181 | GNU@tie{}Guile: | |
372c4bbc DT |
6182 | |
6183 | @example | |
6184 | guix environment guile | |
6185 | @end example | |
6186 | ||
f97c9175 AE |
6187 | If the needed dependencies are not built yet, @command{guix environment} |
6188 | automatically builds them. The environment of the new shell is an augmented | |
372c4bbc DT |
6189 | version of the environment that @command{guix environment} was run in. |
6190 | It contains the necessary search paths for building the given package | |
6191 | added to the existing environment variables. To create a ``pure'' | |
f97c9175 | 6192 | environment, in which the original environment variables have been unset, |
50500f7c LC |
6193 | use the @code{--pure} option@footnote{Users sometimes wrongfully augment |
6194 | environment variables such as @code{PATH} in their @file{~/.bashrc} | |
6195 | file. As a consequence, when @code{guix environment} launches it, Bash | |
6196 | may read @file{~/.bashrc}, thereby introducing ``impurities'' in these | |
6197 | environment variables. It is an error to define such environment | |
6198 | variables in @file{.bashrc}; instead, they should be defined in | |
6199 | @file{.bash_profile}, which is sourced only by log-in shells. | |
6200 | @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for | |
6201 | details on Bash start-up files.}. | |
372c4bbc | 6202 | |
28de8d25 LC |
6203 | @vindex GUIX_ENVIRONMENT |
6204 | @command{guix environment} defines the @code{GUIX_ENVIRONMENT} | |
20185522 LC |
6205 | variable in the shell it spawns; its value is the file name of the |
6206 | profile of this environment. This allows users to, say, define a | |
28de8d25 LC |
6207 | specific prompt for development environments in their @file{.bashrc} |
6208 | (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}): | |
6209 | ||
6210 | @example | |
6211 | if [ -n "$GUIX_ENVIRONMENT" ] | |
6212 | then | |
6213 | export PS1="\u@@\h \w [dev]\$ " | |
6214 | fi | |
6215 | @end example | |
6216 | ||
20185522 LC |
6217 | @noindent |
6218 | ... or to browse the profile: | |
6219 | ||
6220 | @example | |
6221 | $ ls "$GUIX_ENVIRONMENT/bin" | |
6222 | @end example | |
6223 | ||
372c4bbc DT |
6224 | Additionally, more than one package may be specified, in which case the |
6225 | union of the inputs for the given packages are used. For example, the | |
6226 | command below spawns a shell where all of the dependencies of both Guile | |
6227 | and Emacs are available: | |
6228 | ||
6229 | @example | |
6230 | guix environment guile emacs | |
6231 | @end example | |
6232 | ||
1de2fe95 DT |
6233 | Sometimes an interactive shell session is not desired. An arbitrary |
6234 | command may be invoked by placing the @code{--} token to separate the | |
6235 | command from the rest of the arguments: | |
372c4bbc DT |
6236 | |
6237 | @example | |
1de2fe95 | 6238 | guix environment guile -- make -j4 |
372c4bbc DT |
6239 | @end example |
6240 | ||
fe36d84e LC |
6241 | In other situations, it is more convenient to specify the list of |
6242 | packages needed in the environment. For example, the following command | |
6243 | runs @command{python} from an environment containing Python@tie{}2.7 and | |
6244 | NumPy: | |
6245 | ||
6246 | @example | |
1de2fe95 | 6247 | guix environment --ad-hoc python2-numpy python-2.7 -- python |
fe36d84e LC |
6248 | @end example |
6249 | ||
cc90fbbf DT |
6250 | Furthermore, one might want the dependencies of a package and also some |
6251 | additional packages that are not build-time or runtime dependencies, but | |
6252 | are useful when developing nonetheless. Because of this, the | |
6253 | @code{--ad-hoc} flag is positional. Packages appearing before | |
6254 | @code{--ad-hoc} are interpreted as packages whose dependencies will be | |
6255 | added to the environment. Packages appearing after are interpreted as | |
6256 | packages that will be added to the environment directly. For example, | |
6257 | the following command creates a Guix development environment that | |
6258 | additionally includes Git and strace: | |
6259 | ||
6260 | @example | |
6261 | guix environment guix --ad-hoc git strace | |
6262 | @end example | |
6263 | ||
f535dcbe DT |
6264 | Sometimes it is desirable to isolate the environment as much as |
6265 | possible, for maximal purity and reproducibility. In particular, when | |
6266 | using Guix on a host distro that is not GuixSD, it is desirable to | |
6267 | prevent access to @file{/usr/bin} and other system-wide resources from | |
6268 | the development environment. For example, the following command spawns | |
6269 | a Guile REPL in a ``container'' where only the store and the current | |
6270 | working directory are mounted: | |
6271 | ||
6272 | @example | |
6273 | guix environment --ad-hoc --container guile -- guile | |
6274 | @end example | |
6275 | ||
0f252e26 | 6276 | @quotation Note |
cfd35b4e | 6277 | The @code{--container} option requires Linux-libre 3.19 or newer. |
0f252e26 DT |
6278 | @end quotation |
6279 | ||
fe36d84e | 6280 | The available options are summarized below. |
372c4bbc DT |
6281 | |
6282 | @table @code | |
f943c317 LC |
6283 | @item --root=@var{file} |
6284 | @itemx -r @var{file} | |
6285 | @cindex persistent environment | |
6286 | @cindex garbage collector root, for environments | |
6287 | Make @var{file} a symlink to the profile for this environment, and | |
6288 | register it as a garbage collector root. | |
6289 | ||
6290 | This is useful if you want to protect your environment from garbage | |
6291 | collection, to make it ``persistent''. | |
6292 | ||
6293 | When this option is omitted, the environment is protected from garbage | |
6294 | collection only for the duration of the @command{guix environment} | |
6295 | session. This means that next time you recreate the same environment, | |
6296 | you could have to rebuild or re-download packages. | |
6297 | ||
372c4bbc DT |
6298 | @item --expression=@var{expr} |
6299 | @itemx -e @var{expr} | |
c9c282ce DT |
6300 | Create an environment for the package or list of packages that |
6301 | @var{expr} evaluates to. | |
372c4bbc | 6302 | |
fe36d84e LC |
6303 | For example, running: |
6304 | ||
6305 | @example | |
6306 | guix environment -e '(@@ (gnu packages maths) petsc-openmpi)' | |
6307 | @end example | |
6308 | ||
6309 | starts a shell with the environment for this specific variant of the | |
6310 | PETSc package. | |
6311 | ||
c9c282ce DT |
6312 | Running: |
6313 | ||
6314 | @example | |
5c2b2f00 | 6315 | guix environment --ad-hoc -e '(@@ (gnu) %base-packages)' |
c9c282ce DT |
6316 | @end example |
6317 | ||
6318 | starts a shell with all the GuixSD base packages available. | |
6319 | ||
fa445d64 | 6320 | The above commands only use the default output of the given packages. |
779aa003 DT |
6321 | To select other outputs, two element tuples can be specified: |
6322 | ||
6323 | @example | |
6324 | guix environment --ad-hoc -e '(list (@ (gnu packages bash) bash) "include")' | |
6325 | @end example | |
6326 | ||
372c4bbc DT |
6327 | @item --load=@var{file} |
6328 | @itemx -l @var{file} | |
c9c282ce DT |
6329 | Create an environment for the package or list of packages that the code |
6330 | within @var{file} evaluates to. | |
372c4bbc | 6331 | |
fe36d84e LC |
6332 | As an example, @var{file} might contain a definition like this |
6333 | (@pxref{Defining Packages}): | |
6334 | ||
6335 | @example | |
6336 | @verbatiminclude environment-gdb.scm | |
6337 | @end example | |
6338 | ||
a54bd6d7 DT |
6339 | @item --ad-hoc |
6340 | Include all specified packages in the resulting environment, as if an | |
6341 | @i{ad hoc} package were defined with them as inputs. This option is | |
6342 | useful for quickly creating an environment without having to write a | |
6343 | package expression to contain the desired inputs. | |
6344 | ||
6345 | For instance, the command: | |
6346 | ||
6347 | @example | |
1de2fe95 | 6348 | guix environment --ad-hoc guile guile-sdl -- guile |
a54bd6d7 DT |
6349 | @end example |
6350 | ||
6351 | runs @command{guile} in an environment where Guile and Guile-SDL are | |
6352 | available. | |
6353 | ||
417c39f1 | 6354 | Note that this example implicitly asks for the default output of |
f97c9175 | 6355 | @code{guile} and @code{guile-sdl}, but it is possible to ask for a |
417c39f1 LC |
6356 | specific output---e.g., @code{glib:bin} asks for the @code{bin} output |
6357 | of @code{glib} (@pxref{Packages with Multiple Outputs}). | |
6358 | ||
cc90fbbf DT |
6359 | This option may be composed with the default behavior of @command{guix |
6360 | environment}. Packages appearing before @code{--ad-hoc} are interpreted | |
6361 | as packages whose dependencies will be added to the environment, the | |
6362 | default behavior. Packages appearing after are interpreted as packages | |
6363 | that will be added to the environment directly. | |
6364 | ||
372c4bbc DT |
6365 | @item --pure |
6366 | Unset existing environment variables when building the new environment. | |
6367 | This has the effect of creating an environment in which search paths | |
6368 | only contain package inputs. | |
6369 | ||
6370 | @item --search-paths | |
6371 | Display the environment variable definitions that make up the | |
6372 | environment. | |
ce367ef3 LC |
6373 | |
6374 | @item --system=@var{system} | |
6375 | @itemx -s @var{system} | |
6376 | Attempt to build for @var{system}---e.g., @code{i686-linux}. | |
f535dcbe DT |
6377 | |
6378 | @item --container | |
6379 | @itemx -C | |
6380 | @cindex container | |
6381 | Run @var{command} within an isolated container. The current working | |
a01ad638 DT |
6382 | directory outside the container is mapped inside the container. |
6383 | Additionally, a dummy home directory is created that matches the current | |
6384 | user's home directory, and @file{/etc/passwd} is configured accordingly. | |
6385 | The spawned process runs as the current user outside the container, but | |
6386 | has root privileges in the context of the container. | |
f535dcbe DT |
6387 | |
6388 | @item --network | |
6389 | @itemx -N | |
6390 | For containers, share the network namespace with the host system. | |
6391 | Containers created without this flag only have access to the loopback | |
6392 | device. | |
6393 | ||
6394 | @item --expose=@var{source}[=@var{target}] | |
6395 | For containers, expose the file system @var{source} from the host system | |
6396 | as the read-only file system @var{target} within the container. If | |
6397 | @var{target} is not specified, @var{source} is used as the target mount | |
6398 | point in the container. | |
6399 | ||
6400 | The example below spawns a Guile REPL in a container in which the user's | |
6401 | home directory is accessible read-only via the @file{/exchange} | |
6402 | directory: | |
6403 | ||
6404 | @example | |
6405 | guix environment --container --expose=$HOME=/exchange guile -- guile | |
6406 | @end example | |
6407 | ||
5c2b2f00 | 6408 | @item --share=@var{source}[=@var{target}] |
f535dcbe DT |
6409 | For containers, share the file system @var{source} from the host system |
6410 | as the writable 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 for both reading and writing via the | |
6416 | @file{/exchange} directory: | |
6417 | ||
6418 | @example | |
6419 | guix environment --container --share=$HOME=/exchange guile -- guile | |
6420 | @end example | |
372c4bbc DT |
6421 | @end table |
6422 | ||
6423 | It also supports all of the common build options that @command{guix | |
ccd7158d | 6424 | build} supports (@pxref{Common Build Options}). |
372c4bbc | 6425 | |
aff8ce7c DT |
6426 | @node Invoking guix publish |
6427 | @section Invoking @command{guix publish} | |
6428 | ||
e32171ee | 6429 | @cindex @command{guix publish} |
aff8ce7c | 6430 | The purpose of @command{guix publish} is to enable users to easily share |
f97c9175 | 6431 | their store with others, who can then use it as a substitute server |
8ce229fc LC |
6432 | (@pxref{Substitutes}). |
6433 | ||
6434 | When @command{guix publish} runs, it spawns an HTTP server which allows | |
6435 | anyone with network access to obtain substitutes from it. This means | |
6436 | that any machine running Guix can also act as if it were a build farm, | |
6437 | since the HTTP interface is compatible with Hydra, the software behind | |
6438 | the @code{hydra.gnu.org} build farm. | |
aff8ce7c DT |
6439 | |
6440 | For security, each substitute is signed, allowing recipients to check | |
6441 | their authenticity and integrity (@pxref{Substitutes}). Because | |
f97c9175 | 6442 | @command{guix publish} uses the signing key of the system, which is only |
5463fe51 LC |
6443 | readable by the system administrator, it must be started as root; the |
6444 | @code{--user} option makes it drop root privileges early on. | |
aff8ce7c | 6445 | |
b18812b6 LC |
6446 | The signing key pair must be generated before @command{guix publish} is |
6447 | launched, using @command{guix archive --generate-key} (@pxref{Invoking | |
6448 | guix archive}). | |
6449 | ||
aff8ce7c DT |
6450 | The general syntax is: |
6451 | ||
6452 | @example | |
6453 | guix publish @var{options}@dots{} | |
6454 | @end example | |
6455 | ||
6456 | Running @command{guix publish} without any additional arguments will | |
6457 | spawn an HTTP server on port 8080: | |
6458 | ||
6459 | @example | |
6460 | guix publish | |
6461 | @end example | |
6462 | ||
6463 | Once a publishing server has been authorized (@pxref{Invoking guix | |
6464 | archive}), the daemon may download substitutes from it: | |
6465 | ||
6466 | @example | |
6467 | guix-daemon --substitute-urls=http://example.org:8080 | |
6468 | @end example | |
6469 | ||
ff6638d1 LC |
6470 | As a bonus, @command{guix publish} also serves as a content-addressed |
6471 | mirror for source files referenced in @code{origin} records | |
6472 | (@pxref{origin Reference}). For instance, assuming @command{guix | |
6473 | publish} is running on @code{example.org}, the following URL returns the | |
6474 | raw @file{hello-2.10.tar.gz} file with the given SHA256 hash | |
6475 | (represented in @code{nix-base32} format, @pxref{Invoking guix hash}): | |
6476 | ||
6477 | @example | |
6478 | http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i | |
6479 | @end example | |
6480 | ||
6481 | Obviously, these URLs only work for files that are in the store; in | |
6482 | other cases, they return 404 (``Not Found''). | |
6483 | ||
aff8ce7c DT |
6484 | The following options are available: |
6485 | ||
6486 | @table @code | |
6487 | @item --port=@var{port} | |
6488 | @itemx -p @var{port} | |
6489 | Listen for HTTP requests on @var{port}. | |
6490 | ||
9e2292ef LC |
6491 | @item --listen=@var{host} |
6492 | Listen on the network interface for @var{host}. The default is to | |
6493 | accept connections from any interface. | |
6494 | ||
5463fe51 LC |
6495 | @item --user=@var{user} |
6496 | @itemx -u @var{user} | |
6497 | Change privileges to @var{user} as soon as possible---i.e., once the | |
6498 | server socket is open and the signing key has been read. | |
6499 | ||
4a1fc562 LC |
6500 | @item --compression[=@var{level}] |
6501 | @itemx -C [@var{level}] | |
6502 | Compress data using the given @var{level}. When @var{level} is zero, | |
6503 | disable compression. The range 1 to 9 corresponds to different gzip | |
6504 | compression levels: 1 is the fastest, and 9 is the best (CPU-intensive). | |
6505 | The default is 3. | |
6506 | ||
4591c02e | 6507 | Compression occurs on the fly and the compressed streams are not |
4a1fc562 LC |
6508 | cached. Thus, to reduce load on the machine that runs @command{guix |
6509 | publish}, it may be a good idea to choose a low compression level, or to | |
6510 | run @command{guix publish} behind a caching proxy. | |
6511 | ||
e4c7a5f7 LC |
6512 | @item --ttl=@var{ttl} |
6513 | Produce @code{Cache-Control} HTTP headers that advertise a time-to-live | |
6514 | (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5 | |
6515 | days, @code{1m} means 1 month, and so on. | |
6516 | ||
6517 | This allows the user's Guix to keep substitute information in cache for | |
6518 | @var{ttl}. However, note that @code{guix publish} does not itself | |
6519 | guarantee that the store items it provides will indeed remain available | |
6520 | for as long as @var{ttl}. | |
6521 | ||
aff8ce7c DT |
6522 | @item --repl[=@var{port}] |
6523 | @itemx -r [@var{port}] | |
6524 | Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile | |
8ce229fc LC |
6525 | Reference Manual}) on @var{port} (37146 by default). This is used |
6526 | primarily for debugging a running @command{guix publish} server. | |
aff8ce7c DT |
6527 | @end table |
6528 | ||
1c52181f LC |
6529 | Enabling @command{guix publish} on a GuixSD system is a one-liner: just |
6530 | add a call to @code{guix-publish-service} in the @code{services} field | |
6531 | of the @code{operating-system} declaration (@pxref{guix-publish-service, | |
6532 | @code{guix-publish-service}}). | |
6533 | ||
332d7903 HG |
6534 | If you are instead running Guix on a ``foreign distro'', follow these |
6535 | instructions:” | |
6536 | ||
6537 | @itemize | |
6538 | @item | |
6539 | If your host distro uses the systemd init system: | |
6540 | ||
6541 | @example | |
6542 | # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \ | |
6543 | /etc/systemd/system/ | |
6544 | # systemctl start guix-publish && systemctl enable guix-publish | |
6545 | @end example | |
6546 | ||
6547 | @item | |
6548 | If your host distro uses the Upstart init system: | |
6549 | ||
6550 | @example | |
6551 | # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/ | |
6552 | # start guix-publish | |
6553 | @end example | |
6554 | ||
6555 | @item | |
6556 | Otherwise, proceed similarly with your distro's init system. | |
6557 | @end itemize | |
d23c20f1 LC |
6558 | |
6559 | @node Invoking guix challenge | |
6560 | @section Invoking @command{guix challenge} | |
6561 | ||
6562 | @cindex reproducible builds | |
6563 | @cindex verifiable builds | |
e32171ee JD |
6564 | @cindex @command{guix challenge} |
6565 | @cindex challenge | |
d23c20f1 | 6566 | Do the binaries provided by this server really correspond to the source |
f97c9175 | 6567 | code it claims to build? Is a package build process deterministic? |
d23c20f1 LC |
6568 | These are the questions the @command{guix challenge} command attempts to |
6569 | answer. | |
6570 | ||
6571 | The former is obviously an important question: Before using a substitute | |
f97c9175 | 6572 | server (@pxref{Substitutes}), one had better @emph{verify} that it |
d23c20f1 LC |
6573 | provides the right binaries, and thus @emph{challenge} it. The latter |
6574 | is what enables the former: If package builds are deterministic, then | |
6575 | independent builds of the package should yield the exact same result, | |
6576 | bit for bit; if a server provides a binary different from the one | |
6577 | obtained locally, it may be either corrupt or malicious. | |
6578 | ||
6579 | We know that the hash that shows up in @file{/gnu/store} file names is | |
6580 | the hash of all the inputs of the process that built the file or | |
6581 | directory---compilers, libraries, build scripts, | |
6582 | etc. (@pxref{Introduction}). Assuming deterministic build processes, | |
6583 | one store file name should map to exactly one build output. | |
6584 | @command{guix challenge} checks whether there is, indeed, a single | |
6585 | mapping by comparing the build outputs of several independent builds of | |
6586 | any given store item. | |
6587 | ||
f97c9175 | 6588 | The command output looks like this: |
d23c20f1 LC |
6589 | |
6590 | @smallexample | |
ddbc7f7d LC |
6591 | $ guix challenge --substitute-urls="https://hydra.gnu.org https://guix.example.org" |
6592 | updating list of substitutes from 'https://hydra.gnu.org'... 100.0% | |
6593 | updating list of substitutes from 'https://guix.example.org'... 100.0% | |
d23c20f1 LC |
6594 | /gnu/store/@dots{}-openssl-1.0.2d contents differ: |
6595 | local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q | |
ddbc7f7d LC |
6596 | https://hydra.gnu.org/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q |
6597 | https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim | |
d23c20f1 LC |
6598 | /gnu/store/@dots{}-git-2.5.0 contents differ: |
6599 | local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha | |
ddbc7f7d LC |
6600 | https://hydra.gnu.org/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f |
6601 | https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73 | |
d23c20f1 LC |
6602 | /gnu/store/@dots{}-pius-2.1.1 contents differ: |
6603 | local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax | |
ddbc7f7d LC |
6604 | https://hydra.gnu.org/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax |
6605 | https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs | |
d23c20f1 LC |
6606 | @end smallexample |
6607 | ||
6608 | @noindent | |
6609 | In this example, @command{guix challenge} first scans the store to | |
6610 | determine the set of locally-built derivations---as opposed to store | |
6611 | items that were downloaded from a substitute server---and then queries | |
6612 | all the substitute servers. It then reports those store items for which | |
6613 | the servers obtained a result different from the local build. | |
6614 | ||
6615 | @cindex non-determinism, in package builds | |
6616 | As an example, @code{guix.example.org} always gets a different answer. | |
6617 | Conversely, @code{hydra.gnu.org} agrees with local builds, except in the | |
6618 | case of Git. This might indicate that the build process of Git is | |
6619 | non-deterministic, meaning that its output varies as a function of | |
6620 | various things that Guix does not fully control, in spite of building | |
6621 | packages in isolated environments (@pxref{Features}). Most common | |
6622 | sources of non-determinism include the addition of timestamps in build | |
6623 | results, the inclusion of random numbers, and directory listings sorted | |
a70a5004 | 6624 | by inode number. See @uref{https://reproducible-builds.org/docs/}, for |
d23c20f1 LC |
6625 | more information. |
6626 | ||
f97c9175 | 6627 | To find out what is wrong with this Git binary, we can do something along |
d23c20f1 LC |
6628 | these lines (@pxref{Invoking guix archive}): |
6629 | ||
6630 | @example | |
ddbc7f7d | 6631 | $ wget -q -O - https://hydra.gnu.org/nar/@dots{}-git-2.5.0 \ |
d23c20f1 | 6632 | | guix archive -x /tmp/git |
043f4698 | 6633 | $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git |
d23c20f1 LC |
6634 | @end example |
6635 | ||
6636 | This command shows the difference between the files resulting from the | |
6637 | local build, and the files resulting from the build on | |
6638 | @code{hydra.gnu.org} (@pxref{Overview, Comparing and Merging Files,, | |
6639 | diffutils, Comparing and Merging Files}). The @command{diff} command | |
6640 | works great for text files. When binary files differ, a better option | |
ddbc7f7d | 6641 | is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps |
d23c20f1 LC |
6642 | visualize differences for all kinds of files. |
6643 | ||
f97c9175 | 6644 | Once you have done that work, you can tell whether the differences are due |
d23c20f1 LC |
6645 | to a non-deterministic build process or to a malicious server. We try |
6646 | hard to remove sources of non-determinism in packages to make it easier | |
f97c9175 AE |
6647 | to verify substitutes, but of course, this is a process that |
6648 | involves not just Guix, but a large part of the free software community. | |
d23c20f1 LC |
6649 | In the meantime, @command{guix challenge} is one tool to help address |
6650 | the problem. | |
6651 | ||
6652 | If you are writing packages for Guix, you are encouraged to check | |
6653 | whether @code{hydra.gnu.org} and other substitute servers obtain the | |
6654 | same build result as you did with: | |
6655 | ||
6656 | @example | |
6657 | $ guix challenge @var{package} | |
6658 | @end example | |
6659 | ||
6660 | @noindent | |
f97c9175 | 6661 | where @var{package} is a package specification such as |
7cffaeb6 | 6662 | @code{guile@@2.0} or @code{glibc:debug}. |
d23c20f1 LC |
6663 | |
6664 | The general syntax is: | |
6665 | ||
6666 | @example | |
6667 | guix challenge @var{options} [@var{packages}@dots{}] | |
6668 | @end example | |
6669 | ||
7cffaeb6 LC |
6670 | When a difference is found between the hash of a locally-built item and |
6671 | that of a server-provided substitute, or among substitutes provided by | |
6672 | different servers, the command displays it as in the example above and | |
a17417a8 LC |
6673 | its exit code is 2 (other non-zero exit codes denote other kinds of |
6674 | errors.) | |
7cffaeb6 | 6675 | |
d23c20f1 LC |
6676 | The one option that matters is: |
6677 | ||
6678 | @table @code | |
6679 | ||
6680 | @item --substitute-urls=@var{urls} | |
6681 | Consider @var{urls} the whitespace-separated list of substitute source | |
6682 | URLs to compare to. | |
6683 | ||
153b6295 LC |
6684 | @item --verbose |
6685 | @itemx -v | |
6686 | Show details about matches (identical contents) in addition to | |
6687 | information about mismatches. | |
6688 | ||
d23c20f1 LC |
6689 | @end table |
6690 | ||
f11c444d LC |
6691 | @node Invoking guix copy |
6692 | @section Invoking @command{guix copy} | |
6693 | ||
6694 | @cindex copy, of store items, over SSH | |
6695 | @cindex SSH, copy of store items | |
6696 | @cindex sharing store items across machines | |
6697 | @cindex transferring store items across machines | |
6698 | The @command{guix copy} command copies items from the store of one | |
6699 | machine to that of another machine over a secure shell (SSH) | |
6700 | connection@footnote{This command is available only when Guile-SSH was | |
6701 | found. @xref{Requirements}, for details.}. For example, the following | |
6702 | command copies the @code{coreutils} package, the user's profile, and all | |
6703 | their dependencies over to @var{host}, logged in as @var{user}: | |
6704 | ||
6705 | @example | |
6706 | guix copy --to=@var{user}@@@var{host} \ | |
6707 | coreutils `readlink -f ~/.guix-profile` | |
6708 | @end example | |
6709 | ||
6710 | If some of the items to be copied are already present on @var{host}, | |
6711 | they are not actually sent. | |
6712 | ||
6713 | The command below retrieves @code{libreoffice} and @code{gimp} from | |
6714 | @var{host}, assuming they are available there: | |
6715 | ||
6716 | @example | |
6717 | guix copy --from=@var{host} libreoffice gimp | |
6718 | @end example | |
6719 | ||
6720 | The SSH connection is established using the Guile-SSH client, which is | |
6721 | compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and | |
6722 | @file{~/.ssh/config}, and uses the SSH agent for authentication. | |
6723 | ||
6724 | The key used to sign items that are sent must be accepted by the remote | |
6725 | machine. Likewise, the key used by the remote machine to sign items you | |
6726 | are retrieving must be in @file{/etc/guix/acl} so it is accepted by your | |
6727 | own daemon. @xref{Invoking guix archive}, for more information about | |
6728 | store item authentication. | |
6729 | ||
6730 | The general syntax is: | |
6731 | ||
6732 | @example | |
6733 | guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{} | |
6734 | @end example | |
6735 | ||
6736 | You must always specify one of the following options: | |
6737 | ||
6738 | @table @code | |
6739 | @item --to=@var{spec} | |
6740 | @itemx --from=@var{spec} | |
6741 | Specify the host to send to or receive from. @var{spec} must be an SSH | |
6742 | spec such as @code{example.org}, @code{charlie@@example.org}, or | |
6743 | @code{charlie@@example.org:2222}. | |
6744 | @end table | |
6745 | ||
6746 | The @var{items} can be either package names, such as @code{gimp}, or | |
6747 | store items, such as @file{/gnu/store/@dots{}-idutils-4.6}. | |
6748 | ||
6749 | When specifying the name of a package to send, it is first built if | |
6750 | needed, unless @option{--dry-run} was specified. Common build options | |
6751 | are supported (@pxref{Common Build Options}). | |
6752 | ||
d23c20f1 | 6753 | |
32efa254 DT |
6754 | @node Invoking guix container |
6755 | @section Invoking @command{guix container} | |
6756 | @cindex container | |
e32171ee | 6757 | @cindex @command{guix container} |
32efa254 DT |
6758 | @quotation Note |
6759 | As of version @value{VERSION}, this tool is experimental. The interface | |
6760 | is subject to radical change in the future. | |
6761 | @end quotation | |
6762 | ||
6763 | The purpose of @command{guix container} is to manipulate processes | |
6764 | running within an isolated environment, commonly known as a | |
46c36586 | 6765 | ``container'', typically created by the @command{guix environment} |
32efa254 DT |
6766 | (@pxref{Invoking guix environment}) and @command{guix system container} |
6767 | (@pxref{Invoking guix system}) commands. | |
6768 | ||
6769 | The general syntax is: | |
6770 | ||
6771 | @example | |
6772 | guix container @var{action} @var{options}@dots{} | |
6773 | @end example | |
6774 | ||
6775 | @var{action} specifies the operation to perform with a container, and | |
6776 | @var{options} specifies the context-specific arguments for the action. | |
6777 | ||
6778 | The following actions are available: | |
6779 | ||
6780 | @table @code | |
6781 | @item exec | |
6782 | Execute a command within the context of a running container. | |
6783 | ||
6784 | The syntax is: | |
6785 | ||
6786 | @example | |
6787 | guix container exec @var{pid} @var{program} @var{arguments}@dots{} | |
6788 | @end example | |
6789 | ||
6790 | @var{pid} specifies the process ID of the running container. | |
f97c9175 AE |
6791 | @var{program} specifies an executable file name within the root file |
6792 | system of the container. @var{arguments} are the additional options that | |
6793 | will be passed to @var{program}. | |
32efa254 DT |
6794 | |
6795 | The following command launches an interactive login shell inside a | |
6796 | GuixSD container, started by @command{guix system container}, and whose | |
6797 | process ID is 9001: | |
6798 | ||
6799 | @example | |
6800 | guix container exec 9001 /run/current-system/profile/bin/bash --login | |
6801 | @end example | |
6802 | ||
6803 | Note that the @var{pid} cannot be the parent process of a container. It | |
f97c9175 | 6804 | must be PID 1 of the container or one of its child processes. |
32efa254 DT |
6805 | |
6806 | @end table | |
6807 | ||
a1ba8475 LC |
6808 | @c ********************************************************************* |
6809 | @node GNU Distribution | |
6810 | @chapter GNU Distribution | |
6811 | ||
3ca2731c | 6812 | @cindex Guix System Distribution |
4705641f | 6813 | @cindex GuixSD |
3ca2731c LC |
6814 | Guix comes with a distribution of the GNU system consisting entirely of |
6815 | free software@footnote{The term ``free'' here refers to the | |
a1ba8475 | 6816 | @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to |
3ca2731c | 6817 | users of that software}.}. The |
35ed9306 LC |
6818 | distribution can be installed on its own (@pxref{System Installation}), |
6819 | but it is also possible to install Guix as a package manager on top of | |
6820 | an installed GNU/Linux system (@pxref{Installation}). To distinguish | |
3ca2731c | 6821 | between the two, we refer to the standalone distribution as the Guix |
4705641f | 6822 | System Distribution, or GuixSD. |
35ed9306 LC |
6823 | |
6824 | The distribution provides core GNU packages such as GNU libc, GCC, and | |
6825 | Binutils, as well as many GNU and non-GNU applications. The complete | |
6826 | list of available packages can be browsed | |
093ae1be | 6827 | @url{http://www.gnu.org/software/guix/packages,on-line} or by |
d03bb653 | 6828 | running @command{guix package} (@pxref{Invoking guix package}): |
a1ba8475 LC |
6829 | |
6830 | @example | |
e49951eb | 6831 | guix package --list-available |
a1ba8475 LC |
6832 | @end example |
6833 | ||
f97c9175 | 6834 | Our goal is to provide a practical 100% free software distribution of |
401c53c4 LC |
6835 | Linux-based and other variants of GNU, with a focus on the promotion and |
6836 | tight integration of GNU components, and an emphasis on programs and | |
6837 | tools that help users exert that freedom. | |
6838 | ||
3ca2731c | 6839 | Packages are currently available on the following platforms: |
c320011d LC |
6840 | |
6841 | @table @code | |
6842 | ||
6843 | @item x86_64-linux | |
6844 | Intel/AMD @code{x86_64} architecture, Linux-Libre kernel; | |
6845 | ||
6846 | @item i686-linux | |
6847 | Intel 32-bit architecture (IA32), Linux-Libre kernel; | |
6848 | ||
aa1e1947 | 6849 | @item armhf-linux |
aa725117 | 6850 | ARMv7-A architecture with hard float, Thumb-2 and NEON, |
f97c9175 AE |
6851 | using the EABI hard-float application binary interface (ABI), |
6852 | and Linux-Libre kernel. | |
aa1e1947 | 6853 | |
c320011d LC |
6854 | @item mips64el-linux |
6855 | little-endian 64-bit MIPS processors, specifically the Loongson series, | |
f97c9175 | 6856 | n32 ABI, and Linux-Libre kernel. |
c320011d LC |
6857 | |
6858 | @end table | |
6859 | ||
4705641f | 6860 | GuixSD itself is currently only available on @code{i686} and @code{x86_64}. |
3ca2731c | 6861 | |
c320011d LC |
6862 | @noindent |
6863 | For information on porting to other architectures or kernels, | |
f97c9175 | 6864 | @pxref{Porting}. |
c320011d | 6865 | |
401c53c4 | 6866 | @menu |
5af6de3e | 6867 | * System Installation:: Installing the whole operating system. |
35ed9306 | 6868 | * System Configuration:: Configuring the operating system. |
91ef73d4 | 6869 | * Installing Debugging Files:: Feeding the debugger. |
05962f29 | 6870 | * Security Updates:: Deploying security fixes quickly. |
401c53c4 | 6871 | * Package Modules:: Packages from the programmer's viewpoint. |
da7cabd4 | 6872 | * Packaging Guidelines:: Growing the distribution. |
401c53c4 | 6873 | * Bootstrapping:: GNU/Linux built from scratch. |
8b315a6d | 6874 | * Porting:: Targeting another platform or kernel. |
401c53c4 LC |
6875 | @end menu |
6876 | ||
6877 | Building this distribution is a cooperative effort, and you are invited | |
081145cf | 6878 | to join! @xref{Contributing}, for information about how you can help. |
401c53c4 | 6879 | |
5af6de3e LC |
6880 | @node System Installation |
6881 | @section System Installation | |
6882 | ||
e32171ee | 6883 | @cindex installing GuixSD |
3ca2731c | 6884 | @cindex Guix System Distribution |
c8b54374 | 6885 | This section explains how to install the Guix System Distribution (GuixSD) |
3ca2731c | 6886 | on a machine. The Guix package manager can |
35ed9306 LC |
6887 | also be installed on top of a running GNU/Linux system, |
6888 | @pxref{Installation}. | |
5af6de3e LC |
6889 | |
6890 | @ifinfo | |
9c18cf9b | 6891 | @quotation Note |
5af6de3e LC |
6892 | @c This paragraph is for people reading this from tty2 of the |
6893 | @c installation image. | |
1068f26b | 6894 | You are reading this documentation with an Info reader. For details on |
5af6de3e | 6895 | how to use it, hit the @key{RET} key (``return'' or ``enter'') on the |
de341e7c LC |
6896 | link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU |
6897 | Info}. Hit @kbd{l} afterwards to come back here. | |
9c18cf9b LC |
6898 | |
6899 | Alternately, run @command{info info} in another tty to keep the manual | |
6900 | available. | |
6901 | @end quotation | |
5af6de3e LC |
6902 | @end ifinfo |
6903 | ||
dedb8d5e | 6904 | @menu |
e3009f60 LC |
6905 | * Limitations:: What you can expect. |
6906 | * Hardware Considerations:: Supported hardware. | |
6907 | * USB Stick Installation:: Preparing the installation medium. | |
6908 | * Preparing for Installation:: Networking, partitioning, etc. | |
6909 | * Proceeding with the Installation:: The real thing. | |
c8b54374 | 6910 | * Installing GuixSD in a VM:: GuixSD playground. |
e3009f60 | 6911 | * Building the Installation Image:: How this comes to be. |
dedb8d5e LC |
6912 | @end menu |
6913 | ||
6914 | @node Limitations | |
8aaaae38 LC |
6915 | @subsection Limitations |
6916 | ||
4705641f | 6917 | As of version @value{VERSION}, the Guix System Distribution (GuixSD) is |
3ca2731c | 6918 | not production-ready. It may contain bugs and lack important |
8aaaae38 LC |
6919 | features. Thus, if you are looking for a stable production system that |
6920 | respects your freedom as a computer user, a good solution at this point | |
6921 | is to consider @url{http://www.gnu.org/distros/free-distros.html, one of | |
f97c9175 | 6922 | the more established GNU/Linux distributions}. We hope you can soon switch |
4705641f | 6923 | to the GuixSD without fear, of course. In the meantime, you can |
8aaaae38 LC |
6924 | also keep using your distribution and try out the package manager on top |
6925 | of it (@pxref{Installation}). | |
6926 | ||
6927 | Before you proceed with the installation, be aware of the following | |
6928 | noteworthy limitations applicable to version @value{VERSION}: | |
6929 | ||
6930 | @itemize | |
6931 | @item | |
6932 | The installation process does not include a graphical user interface and | |
6933 | requires familiarity with GNU/Linux (see the following subsections to | |
6934 | get a feel of what that means.) | |
6935 | ||
8aaaae38 | 6936 | @item |
dbcb0ab1 | 6937 | Support for the Logical Volume Manager (LVM) is missing. |
8aaaae38 LC |
6938 | |
6939 | @item | |
6940 | Few system services are currently supported out-of-the-box | |
6941 | (@pxref{Services}). | |
6942 | ||
6943 | @item | |
4018745a | 6944 | More than 5,000 packages are available, but you may |
8aaaae38 | 6945 | occasionally find that a useful package is missing. |
5fe01c2d LC |
6946 | |
6947 | @item | |
6948 | GNOME, Xfce, and Enlightenment are available (@pxref{Desktop Services}), | |
6949 | as well as a number of X11 window managers. However, some graphical | |
6950 | applications may be missing, as well as KDE. | |
8aaaae38 LC |
6951 | @end itemize |
6952 | ||
f97c9175 AE |
6953 | You have been warned! But more than a disclaimer, this is an invitation |
6954 | to report issues (and success stories!), and to join us in improving it. | |
8aaaae38 | 6955 | @xref{Contributing}, for more info. |
5af6de3e | 6956 | |
e3009f60 LC |
6957 | |
6958 | @node Hardware Considerations | |
6959 | @subsection Hardware Considerations | |
6960 | ||
6961 | @cindex hardware support on GuixSD | |
6962 | GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It | |
6963 | builds around the kernel Linux-libre, which means that only hardware for | |
e0b3f97e | 6964 | which free software drivers and firmware exist is supported. Nowadays, |
e3009f60 LC |
6965 | a wide range of off-the-shelf hardware is supported on |
6966 | GNU/Linux-libre---from keyboards to graphics cards to scanners and | |
6967 | Ethernet controllers. Unfortunately, there are still areas where | |
6968 | hardware vendors deny users control over their own computing, and such | |
6969 | hardware is not supported on GuixSD. | |
6970 | ||
6971 | @cindex WiFi, hardware support | |
e0b3f97e | 6972 | One of the main areas where free drivers or firmware are lacking is WiFi |
e3009f60 LC |
6973 | devices. WiFi devices known to work include those using Atheros chips |
6974 | (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre | |
52db41af EB |
6975 | driver, and those using Broadcom/AirForce chips (BCM43xx with |
6976 | Wireless-Core Revision 5), which corresponds to the @code{b43-open} | |
6977 | Linux-libre driver. Free firmware exists for both and is available | |
e3009f60 LC |
6978 | out-of-the-box on GuixSD, as part of @var{%base-firmware} |
6979 | (@pxref{operating-system Reference, @code{firmware}}). | |
6980 | ||
6981 | @cindex RYF, Respects Your Freedom | |
6982 | The @uref{https://www.fsf.org/, Free Software Foundation} runs | |
e0b3f97e | 6983 | @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a |
e3009f60 LC |
6984 | certification program for hardware products that respect your freedom |
6985 | and your privacy and ensure that you have control over your device. We | |
e0b3f97e | 6986 | encourage you to check the list of RYF-certified devices. |
e3009f60 LC |
6987 | |
6988 | Another useful resource is the @uref{https://www.h-node.org/, H-Node} | |
6989 | web site. It contains a catalog of hardware devices with information | |
6990 | about their support in GNU/Linux. | |
6991 | ||
6992 | ||
dedb8d5e | 6993 | @node USB Stick Installation |
5af6de3e LC |
6994 | @subsection USB Stick Installation |
6995 | ||
6996 | An installation image for USB sticks can be downloaded from | |
4705641f | 6997 | @indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz}, |
5af6de3e LC |
6998 | where @var{system} is one of: |
6999 | ||
7000 | @table @code | |
7001 | @item x86_64-linux | |
7002 | for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs; | |
7003 | ||
7004 | @item i686-linux | |
7005 | for a 32-bit GNU/Linux system on Intel-compatible CPUs. | |
7006 | @end table | |
7007 | ||
debc6360 LC |
7008 | @c start duplication of authentication part from ``Binary Installation'' |
7009 | Make sure to download the associated @file{.sig} file and to verify the | |
7010 | authenticity of the image against it, along these lines: | |
7011 | ||
7012 | @example | |
7013 | $ wget ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig | |
7014 | $ gpg --verify guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig | |
7015 | @end example | |
7016 | ||
7017 | If that command fails because you do not have the required public key, | |
7018 | then run this command to import it: | |
7019 | ||
7020 | @example | |
7021 | $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID} | |
7022 | @end example | |
7023 | ||
7024 | @noindent | |
7025 | and rerun the @code{gpg --verify} command. | |
7026 | @c end duplication | |
7027 | ||
5af6de3e LC |
7028 | This image contains a single partition with the tools necessary for an |
7029 | installation. It is meant to be copied @emph{as is} to a large-enough | |
7030 | USB stick. | |
7031 | ||
7032 | To copy the image to a USB stick, follow these steps: | |
7033 | ||
7034 | @enumerate | |
7035 | @item | |
7036 | Decompress the image using the @command{xz} command: | |
7037 | ||
7038 | @example | |
4705641f | 7039 | xz -d guixsd-usb-install-@value{VERSION}.@var{system}.xz |
5af6de3e LC |
7040 | @end example |
7041 | ||
7042 | @item | |
f97c9175 AE |
7043 | Insert a USB stick of 1@tie{}GiB or more into your machine, and determine |
7044 | its device name. Assuming that the USB stick is known as @file{/dev/sdX}, | |
5af6de3e LC |
7045 | copy the image with: |
7046 | ||
7047 | @example | |
4705641f | 7048 | dd if=guixsd-usb-install-@value{VERSION}.x86_64 of=/dev/sdX |
5af6de3e LC |
7049 | @end example |
7050 | ||
7051 | Access to @file{/dev/sdX} usually requires root privileges. | |
7052 | @end enumerate | |
7053 | ||
7054 | Once this is done, you should be able to reboot the system and boot from | |
7055 | the USB stick. The latter usually requires you to get in the BIOS' boot | |
7056 | menu, where you can choose to boot from the USB stick. | |
7057 | ||
c8b54374 VL |
7058 | @xref{Installing GuixSD in a VM}, if, instead, you would like to install |
7059 | GuixSD in a virtual machine (VM). | |
7060 | ||
dedb8d5e | 7061 | @node Preparing for Installation |
5af6de3e LC |
7062 | @subsection Preparing for Installation |
7063 | ||
7064 | Once you have successfully booted the image on the USB stick, you should | |
7065 | end up with a root prompt. Several console TTYs are configured and can | |
7066 | be used to run commands as root. TTY2 shows this documentation, | |
de341e7c LC |
7067 | browsable using the Info reader commands (@pxref{Top,,, info-stnd, |
7068 | Stand-alone GNU Info}). The installation system runs the GPM mouse | |
7069 | daemon, which allows you to select text with the left mouse button and | |
7070 | to paste it with the middle button. | |
5af6de3e | 7071 | |
ff925d37 LC |
7072 | @quotation Note |
7073 | Installation requires access to the Internet so that any missing | |
7074 | dependencies of your system configuration can be downloaded. See the | |
7075 | ``Networking'' section below. | |
7076 | @end quotation | |
7077 | ||
0e69cf67 LC |
7078 | The installation system includes many common tools needed for this task. |
7079 | But it is also a full-blown GuixSD system, which means that you can | |
7080 | install additional packages, should you need it, using @command{guix | |
7081 | package} (@pxref{Invoking guix package}). | |
7082 | ||
dedb8d5e | 7083 | @subsubsection Keyboard Layout |
5af6de3e | 7084 | |
dedb8d5e LC |
7085 | @cindex keyboard layout |
7086 | The installation image uses the US qwerty keyboard layout. If you want | |
7087 | to change it, you can use the @command{loadkeys} command. For example, | |
7088 | the following command selects the Dvorak keyboard layout: | |
5af6de3e | 7089 | |
dedb8d5e LC |
7090 | @example |
7091 | loadkeys dvorak | |
7092 | @end example | |
7093 | ||
7094 | See the files under @file{/run/current-system/profile/share/keymaps} for | |
7095 | a list of available keyboard layouts. Run @command{man loadkeys} for | |
7096 | more information. | |
7097 | ||
7098 | @subsubsection Networking | |
7099 | ||
7100 | Run the following command see what your network interfaces are called: | |
235cba85 LC |
7101 | |
7102 | @example | |
dedb8d5e | 7103 | ifconfig -a |
235cba85 LC |
7104 | @end example |
7105 | ||
1713c37f LC |
7106 | @noindent |
7107 | @dots{} or, using the GNU/Linux-specific @command{ip} command: | |
7108 | ||
7109 | @example | |
7110 | ip a | |
7111 | @end example | |
7112 | ||
95c559c1 | 7113 | @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20 |
dedb8d5e LC |
7114 | Wired interfaces have a name starting with @samp{e}; for example, the |
7115 | interface corresponding to the first on-board Ethernet controller is | |
7116 | called @samp{eno1}. Wireless interfaces have a name starting with | |
7117 | @samp{w}, like @samp{w1p2s0}. | |
7118 | ||
7119 | @table @asis | |
7120 | @item Wired connection | |
7121 | To configure a wired network run the following command, substituting | |
7122 | @var{interface} with the name of the wired interface you want to use. | |
7123 | ||
7124 | @example | |
7125 | ifconfig @var{interface} up | |
7126 | @end example | |
7127 | ||
7128 | @item Wireless connection | |
e32171ee JD |
7129 | @cindex wireless |
7130 | @cindex WiFi | |
dedb8d5e LC |
7131 | To configure wireless networking, you can create a configuration file |
7132 | for the @command{wpa_supplicant} configuration tool (its location is not | |
7133 | important) using one of the available text editors such as | |
7134 | @command{zile}: | |
7135 | ||
7136 | @example | |
7137 | zile wpa_supplicant.conf | |
7138 | @end example | |
7139 | ||
7140 | As an example, the following stanza can go to this file and will work | |
7141 | for many wireless networks, provided you give the actual SSID and | |
7142 | passphrase for the network you are connecting to: | |
7143 | ||
7144 | @example | |
7145 | network=@{ | |
ae768308 | 7146 | ssid="@var{my-ssid}" |
dedb8d5e LC |
7147 | key_mgmt=WPA-PSK |
7148 | psk="the network's secret passphrase" | |
7149 | @} | |
7150 | @end example | |
7151 | ||
7152 | Start the wireless service and run it in the background with the | |
7153 | following command (substitute @var{interface} with the name of the | |
7154 | network interface you want to use): | |
7155 | ||
7156 | @example | |
7157 | wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B | |
7158 | @end example | |
7159 | ||
641d0518 | 7160 | Run @command{man wpa_supplicant} for more information. |
dedb8d5e LC |
7161 | @end table |
7162 | ||
e32171ee | 7163 | @cindex DHCP |
dedb8d5e LC |
7164 | At this point, you need to acquire an IP address. On a network where IP |
7165 | addresses are automatically assigned @i{via} DHCP, you can run: | |
7166 | ||
7167 | @example | |
15650ac2 | 7168 | dhclient -v @var{interface} |
dedb8d5e | 7169 | @end example |
5af6de3e | 7170 | |
dedb8d5e LC |
7171 | Try to ping a server to see if networking is up and running: |
7172 | ||
7173 | @example | |
7174 | ping -c 3 gnu.org | |
7175 | @end example | |
5af6de3e LC |
7176 | |
7177 | Setting up network access is almost always a requirement because the | |
7178 | image does not contain all the software and tools that may be needed. | |
7179 | ||
dedb8d5e LC |
7180 | @subsubsection Disk Partitioning |
7181 | ||
7182 | Unless this has already been done, the next step is to partition, and | |
7183 | then format the target partition(s). | |
7184 | ||
7185 | The installation image includes several partitioning tools, including | |
7186 | Parted (@pxref{Overview,,, parted, GNU Parted User Manual}), | |
7187 | @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with | |
7188 | the partition layout you want: | |
7189 | ||
7190 | @example | |
7191 | cfdisk | |
7192 | @end example | |
7193 | ||
d918d79f SB |
7194 | If your disk uses the GUID Partition Table (GPT) format and you plan to |
7195 | install BIOS-based GRUB (which is the default), make sure a BIOS Boot | |
7196 | Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB | |
7197 | manual}). | |
7198 | ||
dedb8d5e LC |
7199 | Once you are done partitioning the target hard disk drive, you have to |
7200 | create a file system on the relevant partition(s)@footnote{Currently | |
b1a505ba DC |
7201 | GuixSD only supports ext4 and btrfs file systems. In particular, code |
7202 | that reads partition UUIDs and labels only works for these file system | |
7203 | types.}. | |
5af6de3e | 7204 | |
7ab44369 LC |
7205 | Preferably, assign partitions a label so that you can easily and |
7206 | reliably refer to them in @code{file-system} declarations (@pxref{File | |
7207 | Systems}). This is typically done using the @code{-L} option of | |
dedb8d5e LC |
7208 | @command{mkfs.ext4} and related commands. So, assuming the target root |
7209 | partition lives at @file{/dev/sda1}, a file system with the label | |
7210 | @code{my-root} can be created with: | |
7ab44369 | 7211 | |
dedb8d5e LC |
7212 | @example |
7213 | mkfs.ext4 -L my-root /dev/sda1 | |
7214 | @end example | |
dd816355 | 7215 | |
13fb1bd9 LC |
7216 | @cindex encrypted disk |
7217 | If you are instead planning to encrypt the root partition, you can use | |
7218 | the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html, | |
7219 | @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}}, | |
7220 | @code{man cryptsetup}} for more information.) Assuming you want to | |
7221 | store the root partition on @file{/dev/sda1}, the command sequence would | |
7222 | be along these lines: | |
6d6e6281 | 7223 | |
13fb1bd9 LC |
7224 | @example |
7225 | cryptsetup luksFormat /dev/sda1 | |
7226 | cryptsetup open --type luks /dev/sda1 my-partition | |
7227 | mkfs.ext4 -L my-root /dev/mapper/my-partition | |
7228 | @end example | |
5af6de3e | 7229 | |
dedb8d5e | 7230 | Once that is done, mount the target root partition under @file{/mnt} |
13fb1bd9 LC |
7231 | with a command like (again, assuming @code{my-root} is the label of the |
7232 | root partition): | |
83a17b62 | 7233 | |
dedb8d5e | 7234 | @example |
13fb1bd9 | 7235 | mount LABEL=my-root /mnt |
dedb8d5e | 7236 | @end example |
83a17b62 | 7237 | |
31b6cdf8 LC |
7238 | Finally, if you plan to use one or more swap partitions (@pxref{Memory |
7239 | Concepts, swap space,, libc, The GNU C Library Reference Manual}), make | |
7240 | sure to initialize them with @command{mkswap}. Assuming you have one | |
7241 | swap partition on @file{/dev/sda2}, you would run: | |
7242 | ||
7243 | @example | |
7244 | mkswap /dev/sda2 | |
b2ff76a0 | 7245 | swapon /dev/sda2 |
31b6cdf8 LC |
7246 | @end example |
7247 | ||
a4ca4362 CM |
7248 | Alternatively, you may use a swap file. For example, assuming that in |
7249 | the new system you want to use the file @file{/swapfile} as a swap file, | |
7250 | you would run@footnote{This example will work for many types of file | |
7251 | systems (e.g., ext4). However, for copy-on-write file systems (e.g., | |
7252 | btrfs), the required steps may be different. For details, see the | |
7253 | manual pages for @command{mkswap} and @command{swapon}.}: | |
7254 | ||
7255 | @example | |
7256 | # This is 10 GiB of swap space. Adjust "count" to change the size. | |
7257 | dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240 | |
7258 | # For security, make the file readable and writable only by root. | |
7259 | chmod 600 /mnt/swapfile | |
7260 | mkswap /mnt/swapfile | |
7261 | swapon /mnt/swapfile | |
7262 | @end example | |
7263 | ||
7264 | Note that if you have encrypted the root partition and created a swap | |
7265 | file in its file system as described above, then the encryption also | |
7266 | protects the swap file, just like any other file in that file system. | |
7267 | ||
dedb8d5e LC |
7268 | @node Proceeding with the Installation |
7269 | @subsection Proceeding with the Installation | |
83a17b62 | 7270 | |
dedb8d5e LC |
7271 | With the target partitions ready and the target root mounted on |
7272 | @file{/mnt}, we're ready to go. First, run: | |
5af6de3e | 7273 | |
dedb8d5e LC |
7274 | @example |
7275 | herd start cow-store /mnt | |
7276 | @end example | |
5af6de3e | 7277 | |
b397c0d5 LC |
7278 | This makes @file{/gnu/store} copy-on-write, such that packages added to it |
7279 | during the installation phase are written to the target disk on @file{/mnt} | |
7280 | rather than kept in memory. This is necessary because the first phase of | |
7281 | the @command{guix system init} command (see below) entails downloads or | |
7282 | builds to @file{/gnu/store} which, initially, is an in-memory file system. | |
5af6de3e | 7283 | |
dedb8d5e | 7284 | Next, you have to edit a file and |
5af6de3e | 7285 | provide the declaration of the operating system to be installed. To |
a8cb87ab LC |
7286 | that end, the installation system comes with three text editors: GNU nano |
7287 | (@pxref{Top,,, nano, GNU nano Manual}), GNU Zile (an Emacs clone), and | |
7288 | nvi (a clone of the original BSD @command{vi} editor). | |
efa77c6c LC |
7289 | We strongly recommend storing that file on the target root file system, say, |
7290 | as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your | |
7291 | configuration file once you have rebooted into the newly-installed system. | |
5af6de3e | 7292 | |
dedb8d5e LC |
7293 | @xref{Using the Configuration System}, for an overview of the |
7294 | configuration file. The example configurations discussed in that | |
7295 | section are available under @file{/etc/configuration} in the | |
7296 | installation image. Thus, to get started with a system configuration | |
7297 | providing a graphical display server (a ``desktop'' system), you can run | |
7298 | something along these lines: | |
7299 | ||
7300 | @example | |
7301 | # mkdir /mnt/etc | |
7302 | # cp /etc/configuration/desktop.scm /mnt/etc/config.scm | |
7303 | # zile /mnt/etc/config.scm | |
7304 | @end example | |
7305 | ||
7306 | You should pay attention to what your configuration file contains, and | |
7307 | in particular: | |
7308 | ||
7309 | @itemize | |
7310 | @item | |
7311 | Make sure the @code{grub-configuration} form refers to the device you | |
7312 | want to install GRUB on. | |
7313 | ||
7314 | @item | |
7315 | Be sure that your partition labels match the value of their respective | |
7316 | @code{device} fields in your @code{file-system} configuration, assuming | |
7317 | your @code{file-system} configuration sets the value of @code{title} to | |
7318 | @code{'label}. | |
13fb1bd9 LC |
7319 | |
7320 | @item | |
7321 | If there are encrypted or RAID partitions, make sure to add a | |
7322 | @code{mapped-devices} field to describe them (@pxref{Mapped Devices}). | |
dedb8d5e | 7323 | @end itemize |
5af6de3e | 7324 | |
dd51caac LC |
7325 | Once you are done preparing the configuration file, the new system must |
7326 | be initialized (remember that the target root file system is mounted | |
7327 | under @file{/mnt}): | |
5af6de3e LC |
7328 | |
7329 | @example | |
7330 | guix system init /mnt/etc/config.scm /mnt | |
7331 | @end example | |
7332 | ||
7333 | @noindent | |
dedb8d5e | 7334 | This copies all the necessary files and installs GRUB on |
5af6de3e | 7335 | @file{/dev/sdX}, unless you pass the @option{--no-grub} option. For |
6621cdb6 | 7336 | more information, @pxref{Invoking guix system}. This command may trigger |
5af6de3e LC |
7337 | downloads or builds of missing packages, which can take some time. |
7338 | ||
1bd4e6db LC |
7339 | Once that command has completed---and hopefully succeeded!---you can run |
7340 | @command{reboot} and boot into the new system. The @code{root} password | |
7341 | in the new system is initially empty; other users' passwords need to be | |
7342 | initialized by running the @command{passwd} command as @code{root}, | |
7343 | unless your configuration specifies otherwise | |
7344 | (@pxref{user-account-password, user account passwords}). | |
7345 | ||
7fcf2a0b LC |
7346 | @cindex upgrading GuixSD |
7347 | From then on, you can update GuixSD whenever you want by running | |
7348 | @command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and | |
7349 | then running @command{guix system reconfigure} to build a new system | |
7350 | generation with the latest packages and services (@pxref{Invoking guix | |
7351 | system}). We recommend doing that regularly so that your system | |
7352 | includes the latest security updates (@pxref{Security Updates}). | |
7353 | ||
1bd4e6db | 7354 | Join us on @code{#guix} on the Freenode IRC network or on |
5af6de3e LC |
7355 | @file{guix-devel@@gnu.org} to share your experience---good or not so |
7356 | good. | |
7357 | ||
c8b54374 VL |
7358 | @node Installing GuixSD in a VM |
7359 | @subsection Installing GuixSD in a Virtual Machine | |
7360 | ||
7361 | @cindex virtual machine, GuixSD installation | |
7362 | If you'd like to install GuixSD in a virtual machine (VM) rather than on | |
7363 | your beloved machine, this section is for you. | |
7364 | ||
7365 | To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a | |
7366 | disk image, follow these steps: | |
7367 | ||
7368 | @enumerate | |
7369 | @item | |
a0885414 LF |
7370 | First, retrieve and decompress the GuixSD installation image as |
7371 | described previously (@pxref{USB Stick Installation}). | |
c8b54374 VL |
7372 | |
7373 | @item | |
7374 | Create a disk image that will hold the installed system. To make a | |
7375 | qcow2-formatted disk image, use the @command{qemu-img} command: | |
7376 | ||
7377 | @example | |
7378 | qemu-img create -f qcow2 guixsd.img 5G | |
7379 | @end example | |
7380 | ||
7381 | This will create a 5GB file. | |
7382 | ||
7383 | @item | |
7384 | Boot the USB installation image in an VM: | |
7385 | ||
7386 | @example | |
7387 | qemu-system-x86_64 -m 1024 -smp 1 \ | |
d36b8457 | 7388 | -net user -net nic,model=virtio -boot menu=on \ |
c8b54374 VL |
7389 | -drive file=guixsd.img \ |
7390 | -drive file=guixsd-usb-install-@value{VERSION}.@var{system} | |
7391 | @end example | |
7392 | ||
7393 | In the VM console, quickly press the @kbd{F12} key to enter the boot | |
7394 | menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your | |
7395 | selection. | |
7396 | ||
7397 | @item | |
7398 | You're now root in the VM, proceed with the installation process. | |
7399 | @xref{Preparing for Installation}, and follow the instructions. | |
7400 | @end enumerate | |
7401 | ||
7402 | Once installation is complete, you can boot the system that's on your | |
7403 | @file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do | |
7404 | that. | |
7405 | ||
dedb8d5e | 7406 | @node Building the Installation Image |
5af6de3e LC |
7407 | @subsection Building the Installation Image |
7408 | ||
e32171ee | 7409 | @cindex installation image |
5af6de3e LC |
7410 | The installation image described above was built using the @command{guix |
7411 | system} command, specifically: | |
7412 | ||
622b2304 | 7413 | @c FIXME: 1G is too much; see <http://bugs.gnu.org/23077>. |
5af6de3e | 7414 | @example |
622b2304 | 7415 | guix system disk-image --image-size=1G gnu/system/install.scm |
5af6de3e LC |
7416 | @end example |
7417 | ||
6e6a0401 AE |
7418 | Have a look at @file{gnu/system/install.scm} in the source tree, |
7419 | and see also @ref{Invoking guix system} for more information | |
5af6de3e LC |
7420 | about the installation image. |
7421 | ||
cf4a9129 LC |
7422 | @node System Configuration |
7423 | @section System Configuration | |
b208a005 | 7424 | |
cf4a9129 | 7425 | @cindex system configuration |
3ca2731c | 7426 | The Guix System Distribution supports a consistent whole-system configuration |
cf4a9129 LC |
7427 | mechanism. By that we mean that all aspects of the global system |
7428 | configuration---such as the available system services, timezone and | |
7429 | locale settings, user accounts---are declared in a single place. Such | |
7430 | a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected. | |
91ef73d4 | 7431 | |
cf4a9129 LC |
7432 | One of the advantages of putting all the system configuration under the |
7433 | control of Guix is that it supports transactional system upgrades, and | |
1068f26b | 7434 | makes it possible to roll back to a previous system instantiation, |
cf4a9129 | 7435 | should something go wrong with the new one (@pxref{Features}). Another |
1068f26b | 7436 | advantage is that it makes it easy to replicate the exact same configuration |
cf4a9129 LC |
7437 | across different machines, or at different points in time, without |
7438 | having to resort to additional administration tools layered on top of | |
1068f26b | 7439 | the own tools of the system. |
cf4a9129 | 7440 | @c Yes, we're talking of Puppet, Chef, & co. here. ↑ |
91ef73d4 | 7441 | |
cf4a9129 LC |
7442 | This section describes this mechanism. First we focus on the system |
7443 | administrator's viewpoint---explaining how the system is configured and | |
7444 | instantiated. Then we show how this mechanism can be extended, for | |
7445 | instance to support new system services. | |
91ef73d4 | 7446 | |
cf4a9129 LC |
7447 | @menu |
7448 | * Using the Configuration System:: Customizing your GNU system. | |
7313a52e | 7449 | * operating-system Reference:: Detail of operating-system declarations. |
cf4a9129 | 7450 | * File Systems:: Configuring file system mounts. |
510f9d86 | 7451 | * Mapped Devices:: Block device extra processing. |
cf4a9129 | 7452 | * User Accounts:: Specifying user accounts. |
598e19dc | 7453 | * Locales:: Language and cultural convention settings. |
cf4a9129 | 7454 | * Services:: Specifying system services. |
0ae8c15a | 7455 | * Setuid Programs:: Programs running with root privileges. |
efb5e833 | 7456 | * X.509 Certificates:: Authenticating HTTPS servers. |
996ed739 | 7457 | * Name Service Switch:: Configuring libc's name service switch. |
fd1b1fa2 | 7458 | * Initial RAM Disk:: Linux-Libre bootstrapping. |
88faf933 | 7459 | * GRUB Configuration:: Configuring the boot loader. |
cf4a9129 | 7460 | * Invoking guix system:: Instantiating a system configuration. |
97d76250 | 7461 | * Running GuixSD in a VM:: How to run GuixSD in a virtual machine. |
cf4a9129 LC |
7462 | * Defining Services:: Adding new service definitions. |
7463 | @end menu | |
91ef73d4 | 7464 | |
cf4a9129 LC |
7465 | @node Using the Configuration System |
7466 | @subsection Using the Configuration System | |
64d76fa6 | 7467 | |
cf4a9129 LC |
7468 | The operating system is configured by providing an |
7469 | @code{operating-system} declaration in a file that can then be passed to | |
7470 | the @command{guix system} command (@pxref{Invoking guix system}). A | |
7471 | simple setup, with the default system services, the default Linux-Libre | |
7472 | kernel, initial RAM disk, and boot loader looks like this: | |
91ef73d4 | 7473 | |
cf4a9129 LC |
7474 | @findex operating-system |
7475 | @lisp | |
dd51caac | 7476 | @include os-config-bare-bones.texi |
cf4a9129 | 7477 | @end lisp |
401c53c4 | 7478 | |
cf4a9129 LC |
7479 | This example should be self-describing. Some of the fields defined |
7480 | above, such as @code{host-name} and @code{bootloader}, are mandatory. | |
7481 | Others, such as @code{packages} and @code{services}, can be omitted, in | |
7482 | which case they get a default value. | |
e7f34eb0 | 7483 | |
5d94ac51 LC |
7484 | Below we discuss the effect of some of the most important fields |
7485 | (@pxref{operating-system Reference}, for details about all the available | |
7486 | fields), and how to @dfn{instantiate} the operating system using | |
7487 | @command{guix system}. | |
7488 | ||
7489 | @unnumberedsubsubsec Globally-Visible Packages | |
7490 | ||
cf4a9129 | 7491 | @vindex %base-packages |
5d94ac51 LC |
7492 | The @code{packages} field lists packages that will be globally visible |
7493 | on the system, for all user accounts---i.e., in every user's @code{PATH} | |
7494 | environment variable---in addition to the per-user profiles | |
7495 | (@pxref{Invoking guix package}). The @var{%base-packages} variable | |
7496 | provides all the tools one would expect for basic user and administrator | |
7497 | tasks---including the GNU Core Utilities, the GNU Networking Utilities, | |
7498 | the GNU Zile lightweight text editor, @command{find}, @command{grep}, | |
7499 | etc. The example above adds tcpdump to those, taken from the @code{(gnu | |
7500 | packages admin)} module (@pxref{Package Modules}). | |
e7f34eb0 | 7501 | |
f6c9fb1b LC |
7502 | @findex specification->package |
7503 | Referring to packages by variable name, like @var{tcpdump} above, has | |
7504 | the advantage of being unambiguous; it also allows typos and such to be | |
7505 | diagnosed right away as ``unbound variables''. The downside is that one | |
7506 | needs to know which module defines which package, and to augment the | |
7507 | @code{use-package-modules} line accordingly. To avoid that, one can use | |
7508 | the @code{specification->package} procedure of the @code{(gnu packages)} | |
7509 | module, which returns the best package for a given name or name and | |
7510 | version: | |
7511 | ||
7512 | @lisp | |
7513 | (use-modules (gnu packages)) | |
7514 | ||
7515 | (operating-system | |
7516 | ;; ... | |
7517 | (packages (append (map specification->package | |
d5e59248 | 7518 | '("tcpdump" "htop" "gnupg@@2.0")) |
f6c9fb1b LC |
7519 | %base-packages))) |
7520 | @end lisp | |
7521 | ||
5d94ac51 LC |
7522 | @unnumberedsubsubsec System Services |
7523 | ||
e32171ee | 7524 | @cindex services |
cf4a9129 LC |
7525 | @vindex %base-services |
7526 | The @code{services} field lists @dfn{system services} to be made | |
7527 | available when the system starts (@pxref{Services}). | |
7528 | The @code{operating-system} declaration above specifies that, in | |
7529 | addition to the basic services, we want the @command{lshd} secure shell | |
cd6f6c22 LC |
7530 | daemon listening on port 2222 (@pxref{Networking Services, |
7531 | @code{lsh-service}}). Under the hood, | |
cf4a9129 LC |
7532 | @code{lsh-service} arranges so that @code{lshd} is started with the |
7533 | right command-line options, possibly with supporting configuration files | |
cd6f6c22 LC |
7534 | generated as needed (@pxref{Defining Services}). |
7535 | ||
7536 | @cindex customization, of services | |
7537 | @findex modify-services | |
7538 | Occasionally, instead of using the base services as is, you will want to | |
4d343a14 CM |
7539 | customize them. To do this, use @code{modify-services} (@pxref{Service |
7540 | Reference, @code{modify-services}}) to modify the list. | |
7541 | ||
7542 | For example, suppose you want to modify @code{guix-daemon} and Mingetty | |
7543 | (the console log-in) in the @var{%base-services} list (@pxref{Base | |
7544 | Services, @code{%base-services}}). To do that, you can write the | |
7545 | following in your operating system declaration: | |
cd6f6c22 LC |
7546 | |
7547 | @lisp | |
4d343a14 CM |
7548 | (define %my-services |
7549 | ;; My very own list of services. | |
7550 | (modify-services %base-services | |
7551 | (guix-service-type config => | |
7552 | (guix-configuration | |
7553 | (inherit config) | |
7554 | (use-substitutes? #f) | |
7555 | (extra-options '("--gc-keep-derivations")))) | |
7556 | (mingetty-service-type config => | |
7557 | (mingetty-configuration | |
317d3b47 | 7558 | (inherit config))))) |
4d343a14 CM |
7559 | |
7560 | (operating-system | |
7561 | ;; @dots{} | |
7562 | (services %my-services)) | |
cd6f6c22 LC |
7563 | @end lisp |
7564 | ||
4d343a14 CM |
7565 | This changes the configuration---i.e., the service parameters---of the |
7566 | @code{guix-service-type} instance, and that of all the | |
7567 | @code{mingetty-service-type} instances in the @var{%base-services} list. | |
7568 | Observe how this is accomplished: first, we arrange for the original | |
7569 | configuration to be bound to the identifier @code{config} in the | |
7570 | @var{body}, and then we write the @var{body} so that it evaluates to the | |
7571 | desired configuration. In particular, notice how we use @code{inherit} | |
7572 | to create a new configuration which has the same values as the old | |
7573 | configuration, but with a few modifications. | |
a1ba8475 | 7574 | |
13fb1bd9 LC |
7575 | @cindex encrypted disk |
7576 | The configuration for a typical ``desktop'' usage, with an encrypted | |
7577 | root partition, the X11 display | |
d038b674 LC |
7578 | server, GNOME and Xfce (users can choose which of these desktop |
7579 | environments to use at the log-in screen by pressing @kbd{F1}), network | |
7580 | management, power management, and more, would look like this: | |
dd51caac LC |
7581 | |
7582 | @lisp | |
7583 | @include os-config-desktop.texi | |
7584 | @end lisp | |
7585 | ||
d038b674 LC |
7586 | A graphical environment with a choice of lightweight window managers |
7587 | instead of full-blown desktop environments would look like this: | |
7588 | ||
7589 | @lisp | |
7590 | @include os-config-lightweight-desktop.texi | |
7591 | @end lisp | |
7592 | ||
dd51caac | 7593 | @xref{Desktop Services}, for the exact list of services provided by |
efb5e833 LC |
7594 | @var{%desktop-services}. @xref{X.509 Certificates}, for background |
7595 | information about the @code{nss-certs} package that is used here. | |
dd51caac | 7596 | |
5d94ac51 LC |
7597 | Again, @var{%desktop-services} is just a list of service objects. If |
7598 | you want to remove services from there, you can do so using the | |
7599 | procedures for list filtering (@pxref{SRFI-1 Filtering and | |
7600 | Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the | |
7601 | following expression returns a list that contains all the services in | |
7602 | @var{%desktop-services} minus the Avahi service: | |
7603 | ||
7604 | @example | |
7605 | (remove (lambda (service) | |
7606 | (eq? (service-kind service) avahi-service-type)) | |
7607 | %desktop-services) | |
7608 | @end example | |
7609 | ||
7610 | @unnumberedsubsubsec Instantiating the System | |
7611 | ||
7612 | Assuming the @code{operating-system} declaration | |
7613 | is stored in the @file{my-system-config.scm} | |
cf4a9129 LC |
7614 | file, the @command{guix system reconfigure my-system-config.scm} command |
7615 | instantiates that configuration, and makes it the default GRUB boot | |
65797bff LC |
7616 | entry (@pxref{Invoking guix system}). |
7617 | ||
1068f26b | 7618 | The normal way to change the system configuration is by updating this |
65797bff | 7619 | file and re-running @command{guix system reconfigure}. One should never |
8b499030 | 7620 | have to touch files in @file{/etc} or to run commands that modify the |
65797bff LC |
7621 | system state such as @command{useradd} or @command{grub-install}. In |
7622 | fact, you must avoid that since that would not only void your warranty | |
7623 | but also prevent you from rolling back to previous versions of your | |
7624 | system, should you ever need to. | |
7625 | ||
7626 | @cindex roll-back, of the operating system | |
7627 | Speaking of roll-back, each time you run @command{guix system | |
7628 | reconfigure}, a new @dfn{generation} of the system is created---without | |
7629 | modifying or deleting previous generations. Old system generations get | |
7630 | an entry in the GRUB boot menu, allowing you to boot them in case | |
7631 | something went wrong with the latest generation. Reassuring, no? The | |
7632 | @command{guix system list-generations} command lists the system | |
067a2e2d CM |
7633 | generations available on disk. It is also possible to roll back the |
7634 | system via the commands @command{guix system roll-back} and | |
7635 | @command{guix system switch-generation}. | |
7636 | ||
7637 | Although the command @command{guix system reconfigure} will not modify | |
7638 | previous generations, must take care when the current generation is not | |
7639 | the latest (e.g., after invoking @command{guix system roll-back}), since | |
7640 | the operation might overwrite a later generation (@pxref{Invoking guix | |
7641 | system}). | |
b81e1947 | 7642 | |
5d94ac51 LC |
7643 | @unnumberedsubsubsec The Programming Interface |
7644 | ||
cf4a9129 LC |
7645 | At the Scheme level, the bulk of an @code{operating-system} declaration |
7646 | is instantiated with the following monadic procedure (@pxref{The Store | |
7647 | Monad}): | |
b81e1947 | 7648 | |
cf4a9129 LC |
7649 | @deffn {Monadic Procedure} operating-system-derivation os |
7650 | Return a derivation that builds @var{os}, an @code{operating-system} | |
7651 | object (@pxref{Derivations}). | |
b81e1947 | 7652 | |
cf4a9129 LC |
7653 | The output of the derivation is a single directory that refers to all |
7654 | the packages, configuration files, and other supporting files needed to | |
7655 | instantiate @var{os}. | |
7656 | @end deffn | |
b81e1947 | 7657 | |
5d94ac51 LC |
7658 | This procedure is provided by the @code{(gnu system)} module. Along |
7659 | with @code{(gnu services)} (@pxref{Services}), this module contains the | |
7660 | guts of GuixSD. Make sure to visit it! | |
7661 | ||
7662 | ||
7313a52e LC |
7663 | @node operating-system Reference |
7664 | @subsection @code{operating-system} Reference | |
7665 | ||
7666 | This section summarizes all the options available in | |
7667 | @code{operating-system} declarations (@pxref{Using the Configuration | |
7668 | System}). | |
7669 | ||
7670 | @deftp {Data Type} operating-system | |
7671 | This is the data type representing an operating system configuration. | |
7672 | By that, we mean all the global system configuration, not per-user | |
7673 | configuration (@pxref{Using the Configuration System}). | |
7674 | ||
7675 | @table @asis | |
7676 | @item @code{kernel} (default: @var{linux-libre}) | |
fbb25e56 | 7677 | The package object of the operating system kernel to use@footnote{Currently |
7313a52e LC |
7678 | only the Linux-libre kernel is supported. In the future, it will be |
7679 | possible to use the GNU@tie{}Hurd.}. | |
7680 | ||
ee2a6304 LC |
7681 | @item @code{kernel-arguments} (default: @code{'()}) |
7682 | List of strings or gexps representing additional arguments to pass on | |
1068f26b | 7683 | the command-line of the kernel---e.g., @code{("console=ttyS0")}. |
ee2a6304 | 7684 | |
7313a52e | 7685 | @item @code{bootloader} |
88faf933 | 7686 | The system bootloader configuration object. @xref{GRUB Configuration}. |
7313a52e LC |
7687 | |
7688 | @item @code{initrd} (default: @code{base-initrd}) | |
e32171ee JD |
7689 | @cindex initrd |
7690 | @cindex initial RAM disk | |
7313a52e LC |
7691 | A two-argument monadic procedure that returns an initial RAM disk for |
7692 | the Linux kernel. @xref{Initial RAM Disk}. | |
7693 | ||
f34c56be LC |
7694 | @item @code{firmware} (default: @var{%base-firmware}) |
7695 | @cindex firmware | |
7696 | List of firmware packages loadable by the operating system kernel. | |
7697 | ||
52db41af EB |
7698 | The default includes firmware needed for Atheros- and Broadcom-based |
7699 | WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open}, | |
7700 | respectively). @xref{Hardware Considerations}, for more info on | |
7701 | supported hardware. | |
f34c56be | 7702 | |
7313a52e LC |
7703 | @item @code{host-name} |
7704 | The host name. | |
7705 | ||
7706 | @item @code{hosts-file} | |
7707 | @cindex hosts file | |
24e02c28 | 7708 | A file-like object (@pxref{G-Expressions, file-like objects}) for use as |
7313a52e | 7709 | @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library |
24e02c28 | 7710 | Reference Manual}). The default is a file with entries for |
7313a52e LC |
7711 | @code{localhost} and @var{host-name}. |
7712 | ||
7713 | @item @code{mapped-devices} (default: @code{'()}) | |
7714 | A list of mapped devices. @xref{Mapped Devices}. | |
7715 | ||
7716 | @item @code{file-systems} | |
7717 | A list of file systems. @xref{File Systems}. | |
7718 | ||
7719 | @item @code{swap-devices} (default: @code{'()}) | |
7720 | @cindex swap devices | |
a4ca4362 CM |
7721 | A list of strings identifying devices or files to be used for ``swap |
7722 | space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference | |
7723 | Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}. | |
7724 | It is possible to specify a swap file in a file system on a mapped | |
7725 | device, provided that the necessary device mapping and file system are | |
7726 | also specified. @xref{Mapped Devices} and @ref{File Systems}. | |
7313a52e | 7727 | |
bf87f38a | 7728 | @item @code{users} (default: @code{%base-user-accounts}) |
7313a52e LC |
7729 | @itemx @code{groups} (default: @var{%base-groups}) |
7730 | List of user accounts and groups. @xref{User Accounts}. | |
7731 | ||
7732 | @item @code{skeletons} (default: @code{(default-skeletons)}) | |
e9dffec1 LC |
7733 | A list target file name/file-like object tuples (@pxref{G-Expressions, |
7734 | file-like objects}). These are the skeleton files that will be added to | |
7735 | the home directory of newly-created user accounts. | |
7313a52e LC |
7736 | |
7737 | For instance, a valid value may look like this: | |
7738 | ||
7739 | @example | |
e9dffec1 LC |
7740 | `((".bashrc" ,(plain-file "bashrc" "echo Hello\n")) |
7741 | (".guile" ,(plain-file "guile" | |
7742 | "(use-modules (ice-9 readline)) | |
7743 | (activate-readline)"))) | |
7313a52e LC |
7744 | @end example |
7745 | ||
7746 | @item @code{issue} (default: @var{%default-issue}) | |
7747 | A string denoting the contents of the @file{/etc/issue} file, which is | |
1068f26b | 7748 | displayed when users log in on a text console. |
7313a52e LC |
7749 | |
7750 | @item @code{packages} (default: @var{%base-packages}) | |
7751 | The set of packages installed in the global profile, which is accessible | |
7752 | at @file{/run/current-system/profile}. | |
7753 | ||
1068f26b | 7754 | The default set includes core utilities and it is good practice to |
7313a52e LC |
7755 | install non-core utilities in user profiles (@pxref{Invoking guix |
7756 | package}). | |
7757 | ||
7758 | @item @code{timezone} | |
7759 | A timezone identifying string---e.g., @code{"Europe/Paris"}. | |
7760 | ||
17c20385 LC |
7761 | You can run the @command{tzselect} command to find out which timezone |
7762 | string corresponds to your region. Choosing an invalid timezone name | |
7763 | causes @command{guix system} to fail. | |
7764 | ||
598e19dc LC |
7765 | @item @code{locale} (default: @code{"en_US.utf8"}) |
7766 | The name of the default locale (@pxref{Locale Names,,, libc, The GNU C | |
7767 | Library Reference Manual}). @xref{Locales}, for more information. | |
7768 | ||
7769 | @item @code{locale-definitions} (default: @var{%default-locale-definitions}) | |
7770 | The list of locale definitions to be compiled and that may be used at | |
7771 | run time. @xref{Locales}. | |
7313a52e | 7772 | |
34760ae7 LC |
7773 | @item @code{locale-libcs} (default: @code{(list @var{glibc})}) |
7774 | The list of GNU@tie{}libc packages whose locale data and tools are used | |
7775 | to build the locale definitions. @xref{Locales}, for compatibility | |
7776 | considerations that justify this option. | |
7777 | ||
996ed739 | 7778 | @item @code{name-service-switch} (default: @var{%default-nss}) |
1068f26b | 7779 | Configuration of the libc name service switch (NSS)---a |
996ed739 LC |
7780 | @code{<name-service-switch>} object. @xref{Name Service Switch}, for |
7781 | details. | |
7782 | ||
7313a52e | 7783 | @item @code{services} (default: @var{%base-services}) |
28d939af | 7784 | A list of service objects denoting system services. @xref{Services}. |
7313a52e LC |
7785 | |
7786 | @item @code{pam-services} (default: @code{(base-pam-services)}) | |
7787 | @cindex PAM | |
7788 | @cindex pluggable authentication modules | |
7789 | Linux @dfn{pluggable authentication module} (PAM) services. | |
7790 | @c FIXME: Add xref to PAM services section. | |
7791 | ||
7792 | @item @code{setuid-programs} (default: @var{%setuid-programs}) | |
7793 | List of string-valued G-expressions denoting setuid programs. | |
7794 | @xref{Setuid Programs}. | |
7795 | ||
f5a9ffa0 AK |
7796 | @item @code{sudoers-file} (default: @var{%sudoers-specification}) |
7797 | @cindex sudoers file | |
84765839 LC |
7798 | The contents of the @file{/etc/sudoers} file as a file-like object |
7799 | (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}). | |
7313a52e LC |
7800 | |
7801 | This file specifies which users can use the @command{sudo} command, what | |
7802 | they are allowed to do, and what privileges they may gain. The default | |
7803 | is that only @code{root} and members of the @code{wheel} group may use | |
7804 | @code{sudo}. | |
7805 | ||
7806 | @end table | |
7807 | @end deftp | |
7808 | ||
cf4a9129 LC |
7809 | @node File Systems |
7810 | @subsection File Systems | |
b81e1947 | 7811 | |
cf4a9129 | 7812 | The list of file systems to be mounted is specified in the |
1068f26b | 7813 | @code{file-systems} field of the operating system declaration |
cf4a9129 LC |
7814 | (@pxref{Using the Configuration System}). Each file system is declared |
7815 | using the @code{file-system} form, like this: | |
b81e1947 LC |
7816 | |
7817 | @example | |
cf4a9129 LC |
7818 | (file-system |
7819 | (mount-point "/home") | |
7820 | (device "/dev/sda3") | |
7821 | (type "ext4")) | |
b81e1947 LC |
7822 | @end example |
7823 | ||
cf4a9129 LC |
7824 | As usual, some of the fields are mandatory---those shown in the example |
7825 | above---while others can be omitted. These are described below. | |
b81e1947 | 7826 | |
cf4a9129 LC |
7827 | @deftp {Data Type} file-system |
7828 | Objects of this type represent file systems to be mounted. They | |
7829 | contain the following members: | |
5ff3c4b8 | 7830 | |
cf4a9129 LC |
7831 | @table @asis |
7832 | @item @code{type} | |
7833 | This is a string specifying the type of the file system---e.g., | |
7834 | @code{"ext4"}. | |
5ff3c4b8 | 7835 | |
cf4a9129 LC |
7836 | @item @code{mount-point} |
7837 | This designates the place where the file system is to be mounted. | |
b81e1947 | 7838 | |
cf4a9129 LC |
7839 | @item @code{device} |
7840 | This names the ``source'' of the file system. By default it is the name | |
7841 | of a node under @file{/dev}, but its meaning depends on the @code{title} | |
7842 | field described below. | |
401c53c4 | 7843 | |
cf4a9129 LC |
7844 | @item @code{title} (default: @code{'device}) |
7845 | This is a symbol that specifies how the @code{device} field is to be | |
7846 | interpreted. | |
401c53c4 | 7847 | |
cf4a9129 LC |
7848 | When it is the symbol @code{device}, then the @code{device} field is |
7849 | interpreted as a file name; when it is @code{label}, then @code{device} | |
7850 | is interpreted as a partition label name; when it is @code{uuid}, | |
7851 | @code{device} is interpreted as a partition unique identifier (UUID). | |
da7cabd4 | 7852 | |
661a1d79 | 7853 | UUIDs may be converted from their string representation (as shown by the |
0767f6a6 LC |
7854 | @command{tune2fs -l} command) using the @code{uuid} form@footnote{The |
7855 | @code{uuid} form expects 16-byte UUIDs as defined in | |
7856 | @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the | |
7857 | form of UUID used by the ext2 family of file systems and others, but it | |
7858 | is different from ``UUIDs'' found in FAT file systems, for instance.}, | |
7859 | like this: | |
661a1d79 LC |
7860 | |
7861 | @example | |
7862 | (file-system | |
7863 | (mount-point "/home") | |
7864 | (type "ext4") | |
7865 | (title 'uuid) | |
7866 | (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))) | |
7867 | @end example | |
7868 | ||
cf4a9129 | 7869 | The @code{label} and @code{uuid} options offer a way to refer to disk |
661a1d79 LC |
7870 | partitions without having to hard-code their actual device |
7871 | name@footnote{Note that, while it is tempting to use | |
7872 | @file{/dev/disk/by-uuid} and similar device names to achieve the same | |
7873 | result, this is not recommended: These special device nodes are created | |
7874 | by the udev daemon and may be unavailable at the time the device is | |
7875 | mounted.}. | |
da7cabd4 | 7876 | |
1068f26b | 7877 | However, when the source of a file system is a mapped device (@pxref{Mapped |
5f86a66e LC |
7878 | Devices}), its @code{device} field @emph{must} refer to the mapped |
7879 | device name---e.g., @file{/dev/mapper/root-partition}---and consequently | |
7880 | @code{title} must be set to @code{'device}. This is required so that | |
7881 | the system knows that mounting the file system depends on having the | |
7882 | corresponding device mapping established. | |
7883 | ||
cf4a9129 LC |
7884 | @item @code{flags} (default: @code{'()}) |
7885 | This is a list of symbols denoting mount flags. Recognized flags | |
2c071ce9 LC |
7886 | include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow |
7887 | access to special files), @code{no-suid} (ignore setuid and setgid | |
7888 | bits), and @code{no-exec} (disallow program execution.) | |
da7cabd4 | 7889 | |
cf4a9129 LC |
7890 | @item @code{options} (default: @code{#f}) |
7891 | This is either @code{#f}, or a string denoting mount options. | |
da7cabd4 | 7892 | |
be21979d LC |
7893 | @item @code{mount?} (default: @code{#t}) |
7894 | This value indicates whether to automatically mount the file system when | |
7895 | the system is brought up. When set to @code{#f}, the file system gets | |
7896 | an entry in @file{/etc/fstab} (read by the @command{mount} command) but | |
7897 | is not automatically mounted. | |
7898 | ||
cf4a9129 LC |
7899 | @item @code{needed-for-boot?} (default: @code{#f}) |
7900 | This Boolean value indicates whether the file system is needed when | |
7901 | booting. If that is true, then the file system is mounted when the | |
7902 | initial RAM disk (initrd) is loaded. This is always the case, for | |
7903 | instance, for the root file system. | |
da7cabd4 | 7904 | |
cf4a9129 LC |
7905 | @item @code{check?} (default: @code{#t}) |
7906 | This Boolean indicates whether the file system needs to be checked for | |
7907 | errors before being mounted. | |
f9cc8971 | 7908 | |
4e469051 LC |
7909 | @item @code{create-mount-point?} (default: @code{#f}) |
7910 | When true, the mount point is created if it does not exist yet. | |
7911 | ||
e51710d1 | 7912 | @item @code{dependencies} (default: @code{'()}) |
13fb1bd9 LC |
7913 | This is a list of @code{<file-system>} or @code{<mapped-device>} objects |
7914 | representing file systems that must be mounted or mapped devices that | |
7915 | must be opened before (and unmounted or closed after) this one. | |
e51710d1 LC |
7916 | |
7917 | As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is | |
7918 | a dependency of @file{/sys/fs/cgroup/cpu} and | |
7919 | @file{/sys/fs/cgroup/memory}. | |
7920 | ||
13fb1bd9 LC |
7921 | Another example is a file system that depends on a mapped device, for |
7922 | example for an encrypted partition (@pxref{Mapped Devices}). | |
cf4a9129 LC |
7923 | @end table |
7924 | @end deftp | |
da7cabd4 | 7925 | |
a69576ea LC |
7926 | The @code{(gnu system file-systems)} exports the following useful |
7927 | variables. | |
7928 | ||
7929 | @defvr {Scheme Variable} %base-file-systems | |
7930 | These are essential file systems that are required on normal systems, | |
cc0e575a | 7931 | such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see |
3392ce5d LC |
7932 | below.) Operating system declarations should always contain at least |
7933 | these. | |
a69576ea LC |
7934 | @end defvr |
7935 | ||
7f239fd3 LC |
7936 | @defvr {Scheme Variable} %pseudo-terminal-file-system |
7937 | This is the file system to be mounted as @file{/dev/pts}. It supports | |
7938 | @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar | |
7939 | functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference | |
7940 | Manual}). Pseudo-terminals are used by terminal emulators such as | |
7941 | @command{xterm}. | |
7942 | @end defvr | |
7943 | ||
db17ae5c LC |
7944 | @defvr {Scheme Variable} %shared-memory-file-system |
7945 | This file system is mounted as @file{/dev/shm} and is used to support | |
7946 | memory sharing across processes (@pxref{Memory-mapped I/O, | |
7947 | @code{shm_open},, libc, The GNU C Library Reference Manual}). | |
7948 | @end defvr | |
7949 | ||
3392ce5d LC |
7950 | @defvr {Scheme Variable} %immutable-store |
7951 | This file system performs a read-only ``bind mount'' of | |
7952 | @file{/gnu/store}, making it read-only for all the users including | |
7953 | @code{root}. This prevents against accidental modification by software | |
7954 | running as @code{root} or by system administrators. | |
7955 | ||
7956 | The daemon itself is still able to write to the store: it remounts it | |
7957 | read-write in its own ``name space.'' | |
7958 | @end defvr | |
7959 | ||
a69576ea LC |
7960 | @defvr {Scheme Variable} %binary-format-file-system |
7961 | The @code{binfmt_misc} file system, which allows handling of arbitrary | |
7962 | executable file types to be delegated to user space. This requires the | |
7963 | @code{binfmt.ko} kernel module to be loaded. | |
7964 | @end defvr | |
7965 | ||
7966 | @defvr {Scheme Variable} %fuse-control-file-system | |
7967 | The @code{fusectl} file system, which allows unprivileged users to mount | |
7968 | and unmount user-space FUSE file systems. This requires the | |
7969 | @code{fuse.ko} kernel module to be loaded. | |
7970 | @end defvr | |
7971 | ||
510f9d86 LC |
7972 | @node Mapped Devices |
7973 | @subsection Mapped Devices | |
7974 | ||
7975 | @cindex device mapping | |
7976 | @cindex mapped devices | |
7977 | The Linux kernel has a notion of @dfn{device mapping}: a block device, | |
7978 | such as a hard disk partition, can be @dfn{mapped} into another device, | |
97c8aef1 | 7979 | usually in @code{/dev/mapper/}, |
510f9d86 LC |
7980 | with additional processing over the data that flows through |
7981 | it@footnote{Note that the GNU@tie{}Hurd makes no difference between the | |
7982 | concept of a ``mapped device'' and that of a file system: both boil down | |
7983 | to @emph{translating} input/output operations made on a file to | |
7984 | operations on its backing store. Thus, the Hurd implements mapped | |
7985 | devices, like file systems, using the generic @dfn{translator} mechanism | |
7986 | (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A | |
7987 | typical example is encryption device mapping: all writes to the mapped | |
7988 | device are encrypted, and all reads are deciphered, transparently. | |
97c8aef1 AE |
7989 | Guix extends this notion by considering any device or set of devices that |
7990 | are @dfn{transformed} in some way to create a new device; for instance, | |
7991 | RAID devices are obtained by @dfn{assembling} several other devices, such | |
7992 | as hard disks or partitions, into a new one that behaves as one partition. | |
7993 | Other examples, not yet implemented, are LVM logical volumes. | |
510f9d86 | 7994 | |
97c8aef1 AE |
7995 | Mapped devices are declared using the @code{mapped-device} form, |
7996 | defined as follows; for examples, see below. | |
510f9d86 LC |
7997 | |
7998 | @deftp {Data Type} mapped-device | |
7999 | Objects of this type represent device mappings that will be made when | |
8000 | the system boots up. | |
8001 | ||
9cb426b8 LC |
8002 | @table @code |
8003 | @item source | |
97c8aef1 AE |
8004 | This is either a string specifying the name of the block device to be mapped, |
8005 | such as @code{"/dev/sda3"}, or a list of such strings when several devices | |
8006 | need to be assembled for creating a new one. | |
510f9d86 | 8007 | |
9cb426b8 | 8008 | @item target |
97c8aef1 AE |
8009 | This string specifies the name of the resulting mapped device. For |
8010 | kernel mappers such as encrypted devices of type @code{luks-device-mapping}, | |
8011 | specifying @code{"my-partition"} leads to the creation of | |
510f9d86 | 8012 | the @code{"/dev/mapper/my-partition"} device. |
97c8aef1 AE |
8013 | For RAID devices of type @code{raid-device-mapping}, the full device name |
8014 | such as @code{"/dev/md0"} needs to be given. | |
510f9d86 | 8015 | |
9cb426b8 | 8016 | @item type |
510f9d86 LC |
8017 | This must be a @code{mapped-device-kind} object, which specifies how |
8018 | @var{source} is mapped to @var{target}. | |
8019 | @end table | |
8020 | @end deftp | |
8021 | ||
8022 | @defvr {Scheme Variable} luks-device-mapping | |
8023 | This defines LUKS block device encryption using the @command{cryptsetup} | |
1068f26b | 8024 | command from the package with the same name. It relies on the |
510f9d86 LC |
8025 | @code{dm-crypt} Linux kernel module. |
8026 | @end defvr | |
8027 | ||
97c8aef1 AE |
8028 | @defvr {Scheme Variable} raid-device-mapping |
8029 | This defines a RAID device, which is assembled using the @code{mdadm} | |
8030 | command from the package with the same name. It requires a Linux kernel | |
8031 | module for the appropriate RAID level to be loaded, such as @code{raid456} | |
8032 | for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10. | |
8033 | @end defvr | |
8034 | ||
8035 | @cindex disk encryption | |
8036 | @cindex LUKS | |
8037 | The following example specifies a mapping from @file{/dev/sda3} to | |
8038 | @file{/dev/mapper/home} using LUKS---the | |
ddf1cd51 | 8039 | @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a |
97c8aef1 AE |
8040 | standard mechanism for disk encryption. |
8041 | The @file{/dev/mapper/home} | |
8042 | device can then be used as the @code{device} of a @code{file-system} | |
8043 | declaration (@pxref{File Systems}). | |
8044 | ||
8045 | @example | |
8046 | (mapped-device | |
8047 | (source "/dev/sda3") | |
8048 | (target "home") | |
8049 | (type luks-device-mapping)) | |
8050 | @end example | |
8051 | ||
8052 | Alternatively, to become independent of device numbering, one may obtain | |
8053 | the LUKS UUID (@dfn{unique identifier}) of the source device by a | |
8054 | command like: | |
8055 | ||
8056 | @example | |
8057 | cryptsetup luksUUID /dev/sda3 | |
8058 | @end example | |
8059 | ||
8060 | and use it as follows: | |
8061 | ||
8062 | @example | |
8063 | (mapped-device | |
8064 | (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44")) | |
8065 | (target "home") | |
8066 | (type luks-device-mapping)) | |
8067 | @end example | |
8068 | ||
a4ca4362 CM |
8069 | @cindex swap encryption |
8070 | It is also desirable to encrypt swap space, since swap space may contain | |
8071 | sensitive data. One way to accomplish that is to use a swap file in a | |
8072 | file system on a device mapped via LUKS encryption. In this way, the | |
8073 | swap file is encrypted because the entire device is encrypted. | |
8074 | @xref{Preparing for Installation,,Disk Partitioning}, for an example. | |
8075 | ||
97c8aef1 AE |
8076 | A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1} |
8077 | may be declared as follows: | |
8078 | ||
8079 | @example | |
8080 | (mapped-device | |
8081 | (source (list "/dev/sda1" "/dev/sdb1")) | |
8082 | (target "/dev/md0") | |
8083 | (type raid-device-mapping)) | |
8084 | @end example | |
8085 | ||
8086 | The @file{/dev/md0} device can then be used as the @code{device} of a | |
8087 | @code{file-system} declaration (@pxref{File Systems}). | |
8088 | Note that the RAID level need not be given; it is chosen during the | |
8089 | initial creation and formatting of the RAID device and is determined | |
8090 | automatically later. | |
8091 | ||
8092 | ||
cf4a9129 LC |
8093 | @node User Accounts |
8094 | @subsection User Accounts | |
ee85f3db | 8095 | |
e32171ee JD |
8096 | @cindex users |
8097 | @cindex accounts | |
8098 | @cindex user accounts | |
9bea87a5 LC |
8099 | User accounts and groups are entirely managed through the |
8100 | @code{operating-system} declaration. They are specified with the | |
8101 | @code{user-account} and @code{user-group} forms: | |
ee85f3db | 8102 | |
cf4a9129 LC |
8103 | @example |
8104 | (user-account | |
8105 | (name "alice") | |
8106 | (group "users") | |
24e752c0 LC |
8107 | (supplementary-groups '("wheel" ;allow use of sudo, etc. |
8108 | "audio" ;sound card | |
8109 | "video" ;video devices such as webcams | |
8110 | "cdrom")) ;the good ol' CD-ROM | |
cf4a9129 LC |
8111 | (comment "Bob's sister") |
8112 | (home-directory "/home/alice")) | |
8113 | @end example | |
25083588 | 8114 | |
9bea87a5 LC |
8115 | When booting or upon completion of @command{guix system reconfigure}, |
8116 | the system ensures that only the user accounts and groups specified in | |
8117 | the @code{operating-system} declaration exist, and with the specified | |
8118 | properties. Thus, account or group creations or modifications made by | |
8119 | directly invoking commands such as @command{useradd} are lost upon | |
8120 | reconfiguration or reboot. This ensures that the system remains exactly | |
8121 | as declared. | |
8122 | ||
cf4a9129 LC |
8123 | @deftp {Data Type} user-account |
8124 | Objects of this type represent user accounts. The following members may | |
8125 | be specified: | |
ee85f3db | 8126 | |
cf4a9129 LC |
8127 | @table @asis |
8128 | @item @code{name} | |
8129 | The name of the user account. | |
ee85f3db | 8130 | |
cf4a9129 | 8131 | @item @code{group} |
e32171ee | 8132 | @cindex groups |
cf4a9129 LC |
8133 | This is the name (a string) or identifier (a number) of the user group |
8134 | this account belongs to. | |
ee85f3db | 8135 | |
cf4a9129 LC |
8136 | @item @code{supplementary-groups} (default: @code{'()}) |
8137 | Optionally, this can be defined as a list of group names that this | |
8138 | account belongs to. | |
ee85f3db | 8139 | |
cf4a9129 LC |
8140 | @item @code{uid} (default: @code{#f}) |
8141 | This is the user ID for this account (a number), or @code{#f}. In the | |
8142 | latter case, a number is automatically chosen by the system when the | |
8143 | account is created. | |
ee85f3db | 8144 | |
cf4a9129 | 8145 | @item @code{comment} (default: @code{""}) |
1068f26b | 8146 | A comment about the account, such as the account owner's full name. |
c8c871d1 | 8147 | |
cf4a9129 LC |
8148 | @item @code{home-directory} |
8149 | This is the name of the home directory for the account. | |
ee85f3db | 8150 | |
eb56ee02 LC |
8151 | @item @code{create-home-directory?} (default: @code{#t}) |
8152 | Indicates whether the home directory of this account should be created | |
8153 | if it does not exist yet. | |
8154 | ||
cf4a9129 LC |
8155 | @item @code{shell} (default: Bash) |
8156 | This is a G-expression denoting the file name of a program to be used as | |
8157 | the shell (@pxref{G-Expressions}). | |
ee85f3db | 8158 | |
cf4a9129 LC |
8159 | @item @code{system?} (default: @code{#f}) |
8160 | This Boolean value indicates whether the account is a ``system'' | |
8161 | account. System accounts are sometimes treated specially; for instance, | |
8162 | graphical login managers do not list them. | |
ee85f3db | 8163 | |
1bd4e6db | 8164 | @anchor{user-account-password} |
cf4a9129 | 8165 | @item @code{password} (default: @code{#f}) |
eb59595c LC |
8166 | You would normally leave this field to @code{#f}, initialize user |
8167 | passwords as @code{root} with the @command{passwd} command, and then let | |
9bea87a5 LC |
8168 | users change it with @command{passwd}. Passwords set with |
8169 | @command{passwd} are of course preserved across reboot and | |
8170 | reconfiguration. | |
eb59595c LC |
8171 | |
8172 | If you @emph{do} want to have a preset password for an account, then | |
8173 | this field must contain the encrypted password, as a string. | |
5d1f1177 LC |
8174 | @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information |
8175 | on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference | |
eb59595c | 8176 | Manual}, for information on Guile's @code{crypt} procedure. |
c8c871d1 | 8177 | |
cf4a9129 LC |
8178 | @end table |
8179 | @end deftp | |
ee85f3db | 8180 | |
e32171ee | 8181 | @cindex groups |
cf4a9129 | 8182 | User group declarations are even simpler: |
ee85f3db | 8183 | |
cf4a9129 LC |
8184 | @example |
8185 | (user-group (name "students")) | |
8186 | @end example | |
ee85f3db | 8187 | |
cf4a9129 LC |
8188 | @deftp {Data Type} user-group |
8189 | This type is for, well, user groups. There are just a few fields: | |
af8a56b8 | 8190 | |
cf4a9129 LC |
8191 | @table @asis |
8192 | @item @code{name} | |
1068f26b | 8193 | The name of the group. |
ee85f3db | 8194 | |
cf4a9129 LC |
8195 | @item @code{id} (default: @code{#f}) |
8196 | The group identifier (a number). If @code{#f}, a new number is | |
8197 | automatically allocated when the group is created. | |
ee85f3db | 8198 | |
c8fa3426 LC |
8199 | @item @code{system?} (default: @code{#f}) |
8200 | This Boolean value indicates whether the group is a ``system'' group. | |
8201 | System groups have low numerical IDs. | |
8202 | ||
cf4a9129 LC |
8203 | @item @code{password} (default: @code{#f}) |
8204 | What, user groups can have a password? Well, apparently yes. Unless | |
1068f26b | 8205 | @code{#f}, this field specifies the password of the group. |
ee85f3db | 8206 | |
cf4a9129 LC |
8207 | @end table |
8208 | @end deftp | |
401c53c4 | 8209 | |
cf4a9129 LC |
8210 | For convenience, a variable lists all the basic user groups one may |
8211 | expect: | |
401c53c4 | 8212 | |
cf4a9129 LC |
8213 | @defvr {Scheme Variable} %base-groups |
8214 | This is the list of basic user groups that users and/or packages expect | |
8215 | to be present on the system. This includes groups such as ``root'', | |
8216 | ``wheel'', and ``users'', as well as groups used to control access to | |
8217 | specific devices such as ``audio'', ``disk'', and ``cdrom''. | |
8218 | @end defvr | |
401c53c4 | 8219 | |
bf87f38a LC |
8220 | @defvr {Scheme Variable} %base-user-accounts |
8221 | This is the list of basic system accounts that programs may expect to | |
8222 | find on a GNU/Linux system, such as the ``nobody'' account. | |
8223 | ||
8224 | Note that the ``root'' account is not included here. It is a | |
8225 | special-case and is automatically added whether or not it is specified. | |
8226 | @end defvr | |
8227 | ||
598e19dc LC |
8228 | @node Locales |
8229 | @subsection Locales | |
8230 | ||
8231 | @cindex locale | |
8232 | A @dfn{locale} defines cultural conventions for a particular language | |
8233 | and region of the world (@pxref{Locales,,, libc, The GNU C Library | |
8234 | Reference Manual}). Each locale has a name that typically has the form | |
b2636518 | 8235 | @code{@var{language}_@var{territory}.@var{codeset}}---e.g., |
598e19dc LC |
8236 | @code{fr_LU.utf8} designates the locale for the French language, with |
8237 | cultural conventions from Luxembourg, and using the UTF-8 encoding. | |
8238 | ||
8239 | @cindex locale definition | |
8240 | Usually, you will want to specify the default locale for the machine | |
8241 | using the @code{locale} field of the @code{operating-system} declaration | |
8242 | (@pxref{operating-system Reference, @code{locale}}). | |
8243 | ||
f5582b2c LC |
8244 | The selected locale is automatically added to the @dfn{locale |
8245 | definitions} known to the system if needed, with its codeset inferred | |
8246 | from its name---e.g., @code{bo_CN.utf8} will be assumed to use the | |
8247 | @code{UTF-8} codeset. Additional locale definitions can be specified in | |
8248 | the @code{locale-definitions} slot of @code{operating-system}---this is | |
8249 | useful, for instance, if the codeset could not be inferred from the | |
8250 | locale name. The default set of locale definitions includes some widely | |
8251 | used locales, but not all the available locales, in order to save space. | |
8252 | ||
8253 | For instance, to add the North Frisian locale for Germany, the value of | |
8254 | that field may be: | |
598e19dc LC |
8255 | |
8256 | @example | |
8257 | (cons (locale-definition | |
8258 | (name "fy_DE.utf8") (source "fy_DE")) | |
8259 | %default-locale-definitions) | |
8260 | @end example | |
8261 | ||
8262 | Likewise, to save space, one might want @code{locale-definitions} to | |
8263 | list only the locales that are actually used, as in: | |
8264 | ||
8265 | @example | |
8266 | (list (locale-definition | |
8267 | (name "ja_JP.eucjp") (source "ja_JP") | |
8268 | (charset "EUC-JP"))) | |
8269 | @end example | |
8270 | ||
5c3c1427 LC |
8271 | @vindex LOCPATH |
8272 | The compiled locale definitions are available at | |
46bd6edd LC |
8273 | @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc |
8274 | version, which is the default location where the GNU@tie{}libc provided | |
8275 | by Guix looks for locale data. This can be overridden using the | |
8276 | @code{LOCPATH} environment variable (@pxref{locales-and-locpath, | |
5c3c1427 LC |
8277 | @code{LOCPATH} and locale packages}). |
8278 | ||
598e19dc LC |
8279 | The @code{locale-definition} form is provided by the @code{(gnu system |
8280 | locale)} module. Details are given below. | |
8281 | ||
8282 | @deftp {Data Type} locale-definition | |
8283 | This is the data type of a locale definition. | |
8284 | ||
8285 | @table @asis | |
8286 | ||
8287 | @item @code{name} | |
8288 | The name of the locale. @xref{Locale Names,,, libc, The GNU C Library | |
8289 | Reference Manual}, for more information on locale names. | |
8290 | ||
8291 | @item @code{source} | |
8292 | The name of the source for that locale. This is typically the | |
8293 | @code{@var{language}_@var{territory}} part of the locale name. | |
8294 | ||
8295 | @item @code{charset} (default: @code{"UTF-8"}) | |
8296 | The ``character set'' or ``code set'' for that locale, | |
8297 | @uref{http://www.iana.org/assignments/character-sets, as defined by | |
8298 | IANA}. | |
8299 | ||
8300 | @end table | |
8301 | @end deftp | |
8302 | ||
8303 | @defvr {Scheme Variable} %default-locale-definitions | |
1068f26b | 8304 | A list of commonly used UTF-8 locales, used as the default |
b2636518 | 8305 | value of the @code{locale-definitions} field of @code{operating-system} |
598e19dc | 8306 | declarations. |
b2636518 LC |
8307 | |
8308 | @cindex locale name | |
8309 | @cindex normalized codeset in locale names | |
8310 | These locale definitions use the @dfn{normalized codeset} for the part | |
8311 | that follows the dot in the name (@pxref{Using gettextized software, | |
8312 | normalized codeset,, libc, The GNU C Library Reference Manual}). So for | |
8313 | instance it has @code{uk_UA.utf8} but @emph{not}, say, | |
8314 | @code{uk_UA.UTF-8}. | |
598e19dc | 8315 | @end defvr |
401c53c4 | 8316 | |
34760ae7 LC |
8317 | @subsubsection Locale Data Compatibility Considerations |
8318 | ||
8319 | @cindex incompatibility, of locale data | |
8320 | @code{operating-system} declarations provide a @code{locale-libcs} field | |
8321 | to specify the GNU@tie{}libc packages that are used to compile locale | |
8322 | declarations (@pxref{operating-system Reference}). ``Why would I | |
8323 | care?'', you may ask. Well, it turns out that the binary format of | |
8324 | locale data is occasionally incompatible from one libc version to | |
8325 | another. | |
8326 | ||
8327 | @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html> | |
8328 | @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>. | |
8329 | For instance, a program linked against libc version 2.21 is unable to | |
8330 | read locale data produced with libc 2.22; worse, that program | |
8331 | @emph{aborts} instead of simply ignoring the incompatible locale | |
8332 | data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip | |
8333 | the incompatible locale data, which is already an improvement.}. | |
8334 | Similarly, a program linked against libc 2.22 can read most, but not | |
201fff9e | 8335 | all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE} |
34760ae7 LC |
8336 | data is incompatible); thus calls to @code{setlocale} may fail, but |
8337 | programs will not abort. | |
8338 | ||
8339 | The ``problem'' in GuixSD is that users have a lot of freedom: They can | |
8340 | choose whether and when to upgrade software in their profiles, and might | |
8341 | be using a libc version different from the one the system administrator | |
8342 | used to build the system-wide locale data. | |
8343 | ||
8344 | Fortunately, unprivileged users can also install their own locale data | |
8345 | and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath, | |
8346 | @code{GUIX_LOCPATH} and locale packages}). | |
8347 | ||
8348 | Still, it is best if the system-wide locale data at | |
8349 | @file{/run/current-system/locale} is built for all the libc versions | |
8350 | actually in use on the system, so that all the programs can access | |
8351 | it---this is especially crucial on a multi-user system. To do that, the | |
8352 | administrator can specify several libc packages in the | |
8353 | @code{locale-libcs} field of @code{operating-system}: | |
8354 | ||
8355 | @example | |
8356 | (use-package-modules base) | |
8357 | ||
8358 | (operating-system | |
8359 | ;; @dots{} | |
8360 | (locale-libcs (list glibc-2.21 (canonical-package glibc)))) | |
8361 | @end example | |
8362 | ||
8363 | This example would lead to a system containing locale definitions for | |
8364 | both libc 2.21 and the current version of libc in | |
8365 | @file{/run/current-system/locale}. | |
8366 | ||
8367 | ||
cf4a9129 LC |
8368 | @node Services |
8369 | @subsection Services | |
401c53c4 | 8370 | |
cf4a9129 LC |
8371 | @cindex system services |
8372 | An important part of preparing an @code{operating-system} declaration is | |
8373 | listing @dfn{system services} and their configuration (@pxref{Using the | |
8374 | Configuration System}). System services are typically daemons launched | |
8375 | when the system boots, or other actions needed at that time---e.g., | |
d8b94dbd LC |
8376 | configuring network access. |
8377 | ||
e8b652d4 LC |
8378 | GuixSD has a broad definition of ``service'' (@pxref{Service |
8379 | Composition}), but many services are managed by the GNU@tie{}Shepherd | |
8380 | (@pxref{Shepherd Services}). On a running system, the @command{herd} | |
8381 | command allows you to list the available services, show their status, | |
8382 | start and stop them, or do other specific operations (@pxref{Jump | |
8383 | Start,,, shepherd, The GNU Shepherd Manual}). For example: | |
d8b94dbd LC |
8384 | |
8385 | @example | |
dd17bc38 | 8386 | # herd status |
d8b94dbd LC |
8387 | @end example |
8388 | ||
8389 | The above command, run as @code{root}, lists the currently defined | |
dd17bc38 | 8390 | services. The @command{herd doc} command shows a synopsis of the given |
d8b94dbd LC |
8391 | service: |
8392 | ||
8393 | @example | |
dd17bc38 | 8394 | # herd doc nscd |
d8b94dbd LC |
8395 | Run libc's name service cache daemon (nscd). |
8396 | @end example | |
8397 | ||
8398 | The @command{start}, @command{stop}, and @command{restart} sub-commands | |
8399 | have the effect you would expect. For instance, the commands below stop | |
8400 | the nscd service and restart the Xorg display server: | |
8401 | ||
8402 | @example | |
dd17bc38 | 8403 | # herd stop nscd |
d8b94dbd | 8404 | Service nscd has been stopped. |
dd17bc38 | 8405 | # herd restart xorg-server |
d8b94dbd LC |
8406 | Service xorg-server has been stopped. |
8407 | Service xorg-server has been started. | |
8408 | @end example | |
401c53c4 | 8409 | |
cf4a9129 | 8410 | The following sections document the available services, starting with |
d8b94dbd LC |
8411 | the core services, that may be used in an @code{operating-system} |
8412 | declaration. | |
401c53c4 | 8413 | |
cf4a9129 LC |
8414 | @menu |
8415 | * Base Services:: Essential system services. | |
c311089b | 8416 | * Scheduled Job Execution:: The mcron service. |
92c03a87 | 8417 | * Log Rotation:: The rottlog service. |
cf4a9129 LC |
8418 | * Networking Services:: Network setup, SSH daemon, etc. |
8419 | * X Window:: Graphical display. | |
f2ec23d1 | 8420 | * Printing Services:: Local and remote printer support. |
fe1a39d3 | 8421 | * Desktop Services:: D-Bus and desktop services. |
105369a4 | 8422 | * Database Services:: SQL databases. |
d8c18af8 | 8423 | * Mail Services:: IMAP, POP3, SMTP, and all that. |
78cef99b | 8424 | * Messaging Services:: Messaging services. |
859e367d | 8425 | * Kerberos Services:: Kerberos services. |
58724c48 | 8426 | * Web Services:: Web servers. |
2be1b471 | 8427 | * VPN Services:: VPN daemons. |
eb419bc9 | 8428 | * Network File System:: NFS related services. |
a7cf4eb6 | 8429 | * Continuous Integration:: The Cuirass service. |
dbc6d370 | 8430 | * Miscellaneous Services:: Other services. |
cf4a9129 | 8431 | @end menu |
401c53c4 | 8432 | |
cf4a9129 LC |
8433 | @node Base Services |
8434 | @subsubsection Base Services | |
a1ba8475 | 8435 | |
cf4a9129 LC |
8436 | The @code{(gnu services base)} module provides definitions for the basic |
8437 | services that one expects from the system. The services exported by | |
8438 | this module are listed below. | |
401c53c4 | 8439 | |
cf4a9129 | 8440 | @defvr {Scheme Variable} %base-services |
31771497 LC |
8441 | This variable contains a list of basic services (@pxref{Service Types |
8442 | and Services}, for more information on service objects) one would | |
cf4a9129 | 8443 | expect from the system: a login service (mingetty) on each tty, syslogd, |
1068f26b | 8444 | the libc name service cache daemon (nscd), the udev device manager, and |
cf4a9129 | 8445 | more. |
401c53c4 | 8446 | |
cf4a9129 LC |
8447 | This is the default value of the @code{services} field of |
8448 | @code{operating-system} declarations. Usually, when customizing a | |
8449 | system, you will want to append services to @var{%base-services}, like | |
8450 | this: | |
401c53c4 | 8451 | |
cf4a9129 | 8452 | @example |
fa1e31b8 | 8453 | (cons* (avahi-service) (lsh-service) %base-services) |
cf4a9129 LC |
8454 | @end example |
8455 | @end defvr | |
401c53c4 | 8456 | |
387e1754 LC |
8457 | @defvr {Scheme Variable} special-files-service-type |
8458 | This is the service that sets up ``special files'' such as | |
8459 | @file{/bin/sh}; an instance of it is part of @code{%base-services}. | |
8460 | ||
8461 | The value associated with @code{special-files-service-type} services | |
8462 | must be a list of tuples where the first element is the ``special file'' | |
8463 | and the second element is its target. By default it is: | |
8464 | ||
8465 | @cindex @file{/bin/sh} | |
8466 | @cindex @file{sh}, in @file{/bin} | |
8467 | @example | |
8468 | `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))) | |
8469 | @end example | |
8470 | ||
8471 | @cindex @file{/usr/bin/env} | |
8472 | @cindex @file{env}, in @file{/usr/bin} | |
8473 | If you want to add, say, @code{/usr/bin/env} to your system, you can | |
8474 | change it to: | |
8475 | ||
8476 | @example | |
8477 | `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")) | |
8478 | ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env"))) | |
8479 | @end example | |
8480 | ||
8481 | Since this is part of @code{%base-services}, you can use | |
8482 | @code{modify-services} to customize the set of special files | |
8483 | (@pxref{Service Reference, @code{modify-services}}). But the simple way | |
8484 | to add a special file is @i{via} the @code{extra-special-file} procedure | |
8485 | (see below.) | |
8486 | @end defvr | |
8487 | ||
8488 | @deffn {Scheme Procedure} extra-special-file @var{file} @var{target} | |
8489 | Use @var{target} as the ``special file'' @var{file}. | |
8490 | ||
8491 | For example, adding the following lines to the @code{services} field of | |
8492 | your operating system declaration leads to a @file{/usr/bin/env} | |
8493 | symlink: | |
8494 | ||
8495 | @example | |
8496 | (extra-special-file "/usr/bin/env" | |
8497 | (file-append coreutils "/bin/env")) | |
8498 | @end example | |
8499 | @end deffn | |
8500 | ||
be1c2c54 | 8501 | @deffn {Scheme Procedure} host-name-service @var{name} |
cf4a9129 LC |
8502 | Return a service that sets the host name to @var{name}. |
8503 | @end deffn | |
401c53c4 | 8504 | |
317d3b47 DC |
8505 | @deffn {Scheme Procedure} login-service @var{config} |
8506 | Return a service to run login according to @var{config}, a | |
8507 | @code{<login-configuration>} object, which specifies the message of the day, | |
8508 | among other things. | |
8509 | @end deffn | |
8510 | ||
8511 | @deftp {Data Type} login-configuration | |
8512 | This is the data type representing the configuration of login. | |
8513 | ||
8514 | @table @asis | |
8515 | ||
8516 | @item @code{motd} | |
e32171ee | 8517 | @cindex message of the day |
317d3b47 DC |
8518 | A file-like object containing the ``message of the day''. |
8519 | ||
8520 | @item @code{allow-empty-passwords?} (default: @code{#t}) | |
8521 | Allow empty passwords by default so that first-time users can log in when | |
8522 | the 'root' account has just been created. | |
8523 | ||
8524 | @end table | |
8525 | @end deftp | |
8526 | ||
66e4f01c LC |
8527 | @deffn {Scheme Procedure} mingetty-service @var{config} |
8528 | Return a service to run mingetty according to @var{config}, a | |
8529 | @code{<mingetty-configuration>} object, which specifies the tty to run, among | |
8530 | other things. | |
cf4a9129 | 8531 | @end deffn |
401c53c4 | 8532 | |
66e4f01c LC |
8533 | @deftp {Data Type} mingetty-configuration |
8534 | This is the data type representing the configuration of Mingetty, which | |
9ee4c9ab | 8535 | provides the default implementation of virtual console log-in. |
66e4f01c LC |
8536 | |
8537 | @table @asis | |
8538 | ||
8539 | @item @code{tty} | |
8540 | The name of the console this Mingetty runs on---e.g., @code{"tty1"}. | |
8541 | ||
66e4f01c LC |
8542 | @item @code{auto-login} (default: @code{#f}) |
8543 | When true, this field must be a string denoting the user name under | |
f9b9a033 | 8544 | which the system automatically logs in. When it is @code{#f}, a |
66e4f01c LC |
8545 | user name and password must be entered to log in. |
8546 | ||
8547 | @item @code{login-program} (default: @code{#f}) | |
8548 | This must be either @code{#f}, in which case the default log-in program | |
8549 | is used (@command{login} from the Shadow tool suite), or a gexp denoting | |
8550 | the name of the log-in program. | |
8551 | ||
8552 | @item @code{login-pause?} (default: @code{#f}) | |
8553 | When set to @code{#t} in conjunction with @var{auto-login}, the user | |
8554 | will have to press a key before the log-in shell is launched. | |
8555 | ||
8556 | @item @code{mingetty} (default: @var{mingetty}) | |
8557 | The Mingetty package to use. | |
8558 | ||
8559 | @end table | |
8560 | @end deftp | |
8561 | ||
9ee4c9ab LF |
8562 | @deffn {Scheme Procedure} agetty-service @var{config} |
8563 | Return a service to run agetty according to @var{config}, an | |
8564 | @code{<agetty-configuration>} object, which specifies the tty to run, | |
8565 | among other things. | |
8566 | @end deffn | |
8567 | ||
8568 | @deftp {Data Type} agetty-configuration | |
8569 | This is the data type representing the configuration of agetty, which | |
8570 | implements virtual and serial console log-in. See the @code{agetty(8)} | |
8571 | man page for more information. | |
8572 | ||
8573 | @table @asis | |
8574 | ||
8575 | @item @code{tty} | |
8576 | The name of the console this agetty runs on, as a string---e.g., | |
8577 | @code{"ttyS0"}. This argument is mandatory. | |
8578 | ||
8579 | @item @code{baud-rate} (default: @code{#f}) | |
8580 | A string containing a comma-separated list of one or more baud rates, in | |
8581 | descending order. | |
8582 | ||
8583 | @item @code{term} (default: @code{#f}) | |
8584 | A string containing the value used for the @code{TERM} environment | |
8585 | variable. | |
8586 | ||
8587 | @item @code{eight-bits?} (default: @code{#f}) | |
8588 | When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is | |
8589 | disabled. | |
8590 | ||
8591 | @item @code{auto-login} (default: @code{#f}) | |
8592 | When passed a login name, as a string, the specified user will be logged | |
8593 | in automatically without prompting for their login name or password. | |
8594 | ||
8595 | @item @code{no-reset?} (default: @code{#f}) | |
8596 | When @code{#t}, don't reset terminal cflags (control modes). | |
8597 | ||
8598 | @item @code{host} (default: @code{#f}) | |
8599 | This accepts a string containing the "login_host", which will be written | |
8600 | into the @file{/var/run/utmpx} file. | |
8601 | ||
8602 | @item @code{remote?} (default: @code{#f}) | |
8603 | When set to @code{#t} in conjunction with @var{host}, this will add an | |
8604 | @code{-r} fakehost option to the command line of the login program | |
8605 | specified in @var{login-program}. | |
8606 | ||
8607 | @item @code{flow-control?} (default: @code{#f}) | |
8608 | When set to @code{#t}, enable hardware (RTS/CTS) flow control. | |
8609 | ||
8610 | @item @code{no-issue?} (default: @code{#f}) | |
8611 | When set to @code{#t}, the contents of the @file{/etc/issue} file will | |
8612 | not be displayed before presenting the login prompt. | |
8613 | ||
8614 | @item @code{init-string} (default: @code{#f}) | |
8615 | This accepts a string that will be sent to the tty or modem before | |
8616 | sending anything else. It can be used to initialize a modem. | |
8617 | ||
8618 | @item @code{no-clear?} (default: @code{#f}) | |
8619 | When set to @code{#t}, agetty will not clear the screen before showing | |
8620 | the login prompt. | |
8621 | ||
8622 | @item @code{login-program} (default: (file-append shadow "/bin/login")) | |
8623 | This must be either a gexp denoting the name of a log-in program, or | |
8624 | unset, in which case the default value is the @command{login} from the | |
8625 | Shadow tool suite. | |
8626 | ||
8627 | @item @code{local-line} (default: @code{#f}) | |
8628 | Control the CLOCAL line flag. This accepts one of three symbols as | |
8629 | arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f}, | |
8630 | the default value chosen by agetty is @code{'auto}. | |
8631 | ||
8632 | @item @code{extract-baud?} (default: @code{#f}) | |
8633 | When set to @code{#t}, instruct agetty to try to extract the baud rate | |
8634 | from the status messages produced by certain types of modems. | |
8635 | ||
8636 | @item @code{skip-login?} (default: @code{#f}) | |
8637 | When set to @code{#t}, do not prompt the user for a login name. This | |
8638 | can be used with @var{login-program} field to use non-standard login | |
8639 | systems. | |
8640 | ||
8641 | @item @code{no-newline?} (default: @code{#f}) | |
8642 | When set to @code{#t}, do not print a newline before printing the | |
8643 | @file{/etc/issue} file. | |
8644 | ||
8645 | @c Is this dangerous only when used with login-program, or always? | |
8646 | @item @code{login-options} (default: @code{#f}) | |
8647 | This option accepts a string containing options that are passed to the | |
8648 | login program. When used with the @var{login-program}, be aware that a | |
8649 | malicious user could try to enter a login name containing embedded | |
8650 | options that could be parsed by the login program. | |
8651 | ||
8652 | @item @code{login-pause} (default: @code{#f}) | |
8653 | When set to @code{#t}, wait for any key before showing the login prompt. | |
8654 | This can be used in conjunction with @var{auto-login} to save memory by | |
8655 | lazily spawning shells. | |
8656 | ||
8657 | @item @code{chroot} (default: @code{#f}) | |
8658 | Change root to the specified directory. This option accepts a directory | |
8659 | path as a string. | |
8660 | ||
8661 | @item @code{hangup?} (default: @code{#f}) | |
8662 | Use the Linux system call @code{vhangup} to do a virtual hangup of the | |
8663 | specified terminal. | |
8664 | ||
8665 | @item @code{keep-baud?} (default: @code{#f}) | |
8666 | When set to @code{#t}, try to keep the existing baud rate. The baud | |
8667 | rates from @var{baud-rate} are used when agetty receives a @key{BREAK} | |
8668 | character. | |
8669 | ||
8670 | @item @code{timeout} (default: @code{#f}) | |
8671 | When set to an integer value, terminate if no user name could be read | |
8672 | within @var{timeout} seconds. | |
8673 | ||
8674 | @item @code{detect-case?} (default: @code{#f}) | |
8675 | When set to @code{#t}, turn on support for detecting an uppercase-only | |
8676 | terminal. This setting will detect a login name containing only | |
8677 | uppercase letters as indicating an uppercase-only terminal and turn on | |
8678 | some upper-to-lower case conversions. Note that this will not support | |
8679 | Unicode characters. | |
8680 | ||
8681 | @item @code{wait-cr?} (default: @code{#f}) | |
8682 | When set to @code{#t}, wait for the user or modem to send a | |
8683 | carriage-return or linefeed character before displaying | |
8684 | @file{/etc/issue} or login prompt. This is typically used with the | |
8685 | @var{init-string} option. | |
8686 | ||
8687 | @item @code{no-hints?} (default: @code{#f}) | |
8688 | When set to @code{#t}, do not print hints about Num, Caps, and Scroll | |
8689 | locks. | |
8690 | ||
8691 | @item @code{no-hostname?} (default: @code{#f}) | |
8692 | By default, the hostname is printed. When this option is set to | |
8693 | @code{#t}, no hostname will be shown at all. | |
8694 | ||
8695 | @item @code{long-hostname?} (default: @code{#f}) | |
8696 | By default, the hostname is only printed until the first dot. When this | |
8697 | option is set to @code{#t}, the fully qualified hostname by | |
8698 | @code{gethostname} or @code{getaddrinfo} is shown. | |
8699 | ||
8700 | @item @code{erase-characters} (default: @code{#f}) | |
8701 | This option accepts a string of additional characters that should be | |
8702 | interpreted as backspace when the user types their login name. | |
8703 | ||
8704 | @item @code{kill-characters} (default: @code{#f}) | |
8705 | This option accepts a string that should be interpreted to mean "ignore | |
8706 | all previous characters" (also called a "kill" character) when the types | |
8707 | their login name. | |
8708 | ||
8709 | @item @code{chdir} (default: @code{#f}) | |
8710 | This option accepts, as a string, a directory path that will be changed | |
8711 | to before login. | |
8712 | ||
8713 | @item @code{delay} (default: @code{#f}) | |
8714 | This options accepts, as an integer, the number of seconds to sleep | |
8715 | before opening the tty and displaying the login prompt. | |
8716 | ||
8717 | @item @code{nice} (default: @code{#f}) | |
8718 | This option accepts, as an integer, the nice value with which to run the | |
8719 | @command{login} program. | |
8720 | ||
8721 | @item @code{extra-options} (default: @code{'()}) | |
8722 | This option provides an "escape hatch" for the user to provide arbitrary | |
8723 | command-line arguments to @command{agetty} as a list of strings. | |
8724 | ||
8725 | @end table | |
8726 | @end deftp | |
8727 | ||
46ec2707 DC |
8728 | @deffn {Scheme Procedure} kmscon-service-type @var{config} |
8729 | Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon} | |
8730 | according to @var{config}, a @code{<kmscon-configuration>} object, which | |
8731 | specifies the tty to run, among other things. | |
8732 | @end deffn | |
8733 | ||
8734 | @deftp {Data Type} kmscon-configuration | |
8735 | This is the data type representing the configuration of Kmscon, which | |
9ee4c9ab | 8736 | implements virtual console log-in. |
46ec2707 DC |
8737 | |
8738 | @table @asis | |
8739 | ||
8740 | @item @code{virtual-terminal} | |
8741 | The name of the console this Kmscon runs on---e.g., @code{"tty1"}. | |
8742 | ||
8743 | @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")}) | |
8744 | A gexp denoting the name of the log-in program. The default log-in program is | |
8745 | @command{login} from the Shadow tool suite. | |
8746 | ||
8747 | @item @code{login-arguments} (default: @code{'("-p")}) | |
8748 | A list of arguments to pass to @command{login}. | |
8749 | ||
8750 | @item @code{hardware-acceleration?} (default: #f) | |
8751 | Whether to use hardware acceleration. | |
8752 | ||
8753 | @item @code{kmscon} (default: @var{kmscon}) | |
8754 | The Kmscon package to use. | |
8755 | ||
8756 | @end table | |
8757 | @end deftp | |
8758 | ||
6454b333 LC |
8759 | @cindex name service cache daemon |
8760 | @cindex nscd | |
be1c2c54 | 8761 | @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @ |
4aee6e60 | 8762 | [#:name-services '()] |
1068f26b | 8763 | Return a service that runs the libc name service cache daemon (nscd) with the |
b893f1ae LC |
8764 | given @var{config}---an @code{<nscd-configuration>} object. @xref{Name |
8765 | Service Switch}, for an example. | |
cf4a9129 | 8766 | @end deffn |
401c53c4 | 8767 | |
6454b333 LC |
8768 | @defvr {Scheme Variable} %nscd-default-configuration |
8769 | This is the default @code{<nscd-configuration>} value (see below) used | |
1068f26b | 8770 | by @code{nscd-service}. It uses the caches defined by |
6454b333 LC |
8771 | @var{%nscd-default-caches}; see below. |
8772 | @end defvr | |
8773 | ||
8774 | @deftp {Data Type} nscd-configuration | |
1068f26b | 8775 | This is the data type representing the name service cache daemon (nscd) |
6454b333 LC |
8776 | configuration. |
8777 | ||
8778 | @table @asis | |
8779 | ||
b893f1ae LC |
8780 | @item @code{name-services} (default: @code{'()}) |
8781 | List of packages denoting @dfn{name services} that must be visible to | |
8782 | the nscd---e.g., @code{(list @var{nss-mdns})}. | |
8783 | ||
8784 | @item @code{glibc} (default: @var{glibc}) | |
8785 | Package object denoting the GNU C Library providing the @command{nscd} | |
8786 | command. | |
8787 | ||
6454b333 | 8788 | @item @code{log-file} (default: @code{"/var/log/nscd.log"}) |
1068f26b | 8789 | Name of the nscd log file. This is where debugging output goes when |
6454b333 LC |
8790 | @code{debug-level} is strictly positive. |
8791 | ||
8792 | @item @code{debug-level} (default: @code{0}) | |
1068f26b | 8793 | Integer denoting the debugging levels. Higher numbers mean that more |
6454b333 LC |
8794 | debugging output is logged. |
8795 | ||
8796 | @item @code{caches} (default: @var{%nscd-default-caches}) | |
8797 | List of @code{<nscd-cache>} objects denoting things to be cached; see | |
8798 | below. | |
8799 | ||
8800 | @end table | |
8801 | @end deftp | |
8802 | ||
8803 | @deftp {Data Type} nscd-cache | |
8804 | Data type representing a cache database of nscd and its parameters. | |
8805 | ||
8806 | @table @asis | |
8807 | ||
8808 | @item @code{database} | |
8809 | This is a symbol representing the name of the database to be cached. | |
8810 | Valid values are @code{passwd}, @code{group}, @code{hosts}, and | |
8811 | @code{services}, which designate the corresponding NSS database | |
8812 | (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}). | |
8813 | ||
8814 | @item @code{positive-time-to-live} | |
8815 | @itemx @code{negative-time-to-live} (default: @code{20}) | |
8816 | A number representing the number of seconds during which a positive or | |
8817 | negative lookup result remains in cache. | |
8818 | ||
8819 | @item @code{check-files?} (default: @code{#t}) | |
8820 | Whether to check for updates of the files corresponding to | |
8821 | @var{database}. | |
8822 | ||
8823 | For instance, when @var{database} is @code{hosts}, setting this flag | |
8824 | instructs nscd to check for updates in @file{/etc/hosts} and to take | |
8825 | them into account. | |
8826 | ||
8827 | @item @code{persistent?} (default: @code{#t}) | |
8828 | Whether the cache should be stored persistently on disk. | |
8829 | ||
8830 | @item @code{shared?} (default: @code{#t}) | |
8831 | Whether the cache should be shared among users. | |
8832 | ||
8833 | @item @code{max-database-size} (default: 32@tie{}MiB) | |
8834 | Maximum size in bytes of the database cache. | |
8835 | ||
8836 | @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert | |
8837 | @c settings, so leave them out. | |
8838 | ||
8839 | @end table | |
8840 | @end deftp | |
8841 | ||
8842 | @defvr {Scheme Variable} %nscd-default-caches | |
8843 | List of @code{<nscd-cache>} objects used by default by | |
1068f26b | 8844 | @code{nscd-configuration} (see above). |
6454b333 LC |
8845 | |
8846 | It enables persistent and aggressive caching of service and host name | |
8847 | lookups. The latter provides better host name lookup performance, | |
8848 | resilience in the face of unreliable name servers, and also better | |
8849 | privacy---often the result of host name lookups is in local cache, so | |
8850 | external name servers do not even need to be queried. | |
8851 | @end defvr | |
8852 | ||
ec2e2f6c | 8853 | @anchor{syslog-configuration-type} |
e32171ee JD |
8854 | @cindex syslog |
8855 | @cindex logging | |
ec2e2f6c DC |
8856 | @deftp {Data Type} syslog-configuration |
8857 | This data type represents the configuration of the syslog daemon. | |
6454b333 | 8858 | |
ec2e2f6c DC |
8859 | @table @asis |
8860 | @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")}) | |
8861 | The syslog daemon to use. | |
8862 | ||
8863 | @item @code{config-file} (default: @code{%default-syslog.conf}) | |
8864 | The syslog configuration file to use. | |
8865 | ||
8866 | @end table | |
8867 | @end deftp | |
8868 | ||
8869 | @anchor{syslog-service} | |
e32171ee | 8870 | @cindex syslog |
ec2e2f6c DC |
8871 | @deffn {Scheme Procedure} syslog-service @var{config} |
8872 | Return a service that runs a syslog daemon according to @var{config}. | |
44abcb28 LC |
8873 | |
8874 | @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more | |
8875 | information on the configuration file syntax. | |
cf4a9129 | 8876 | @end deffn |
401c53c4 | 8877 | |
0adfe95a LC |
8878 | @anchor{guix-configuration-type} |
8879 | @deftp {Data Type} guix-configuration | |
8880 | This data type represents the configuration of the Guix build daemon. | |
8881 | @xref{Invoking guix-daemon}, for more information. | |
8882 | ||
8883 | @table @asis | |
8884 | @item @code{guix} (default: @var{guix}) | |
8885 | The Guix package to use. | |
401c53c4 | 8886 | |
0adfe95a LC |
8887 | @item @code{build-group} (default: @code{"guixbuild"}) |
8888 | Name of the group for build user accounts. | |
401c53c4 | 8889 | |
0adfe95a LC |
8890 | @item @code{build-accounts} (default: @code{10}) |
8891 | Number of build user accounts to create. | |
401c53c4 | 8892 | |
0adfe95a | 8893 | @item @code{authorize-key?} (default: @code{#t}) |
e32171ee | 8894 | @cindex substitutes, authorization thereof |
5b58c28b LC |
8895 | Whether to authorize the substitute keys listed in |
8896 | @code{authorized-keys}---by default that of @code{hydra.gnu.org} | |
0adfe95a LC |
8897 | (@pxref{Substitutes}). |
8898 | ||
5b58c28b LC |
8899 | @vindex %default-authorized-guix-keys |
8900 | @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys}) | |
8901 | The list of authorized key files for archive imports, as a list of | |
8902 | string-valued gexps (@pxref{Invoking guix archive}). By default, it | |
8903 | contains that of @code{hydra.gnu.org} (@pxref{Substitutes}). | |
8904 | ||
0adfe95a LC |
8905 | @item @code{use-substitutes?} (default: @code{#t}) |
8906 | Whether to use substitutes. | |
8907 | ||
b0b9f6e0 LC |
8908 | @item @code{substitute-urls} (default: @var{%default-substitute-urls}) |
8909 | The list of URLs where to look for substitutes by default. | |
8910 | ||
0adfe95a LC |
8911 | @item @code{extra-options} (default: @code{'()}) |
8912 | List of extra command-line options for @command{guix-daemon}. | |
8913 | ||
dc0ef095 LC |
8914 | @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"}) |
8915 | File where @command{guix-daemon}'s standard output and standard error | |
8916 | are written. | |
8917 | ||
0adfe95a | 8918 | @item @code{lsof} (default: @var{lsof}) |
f78903f3 | 8919 | The lsof package to use. |
0adfe95a | 8920 | |
93d32da9 LF |
8921 | @item @code{http-proxy} (default: @code{#f}) |
8922 | The HTTP proxy used for downloading fixed-output derivations and | |
8923 | substitutes. | |
8924 | ||
b191f0a6 LF |
8925 | @item @code{tmpdir} (default: @code{#f}) |
8926 | A directory path where the @command{guix-daemon} will perform builds. | |
8927 | ||
0adfe95a LC |
8928 | @end table |
8929 | @end deftp | |
8930 | ||
8931 | @deffn {Scheme Procedure} guix-service @var{config} | |
8932 | Return a service that runs the Guix build daemon according to | |
8933 | @var{config}. | |
cf4a9129 | 8934 | @end deffn |
a1ba8475 | 8935 | |
be1c2c54 | 8936 | @deffn {Scheme Procedure} udev-service [#:udev udev] |
cf4a9129 LC |
8937 | Run @var{udev}, which populates the @file{/dev} directory dynamically. |
8938 | @end deffn | |
401c53c4 | 8939 | |
a535e122 LF |
8940 | @deffn {Scheme Procedure} urandom-seed-service @var{#f} |
8941 | Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom} | |
8942 | when rebooting. | |
8943 | @end deffn | |
8944 | ||
8945 | @defvr {Scheme Variable} %random-seed-file | |
8946 | This is the name of the file where some random bytes are saved by | |
8947 | @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting. | |
8948 | It defaults to @file{/var/lib/random-seed}. | |
8949 | @end defvr | |
8950 | ||
e32171ee JD |
8951 | @cindex keymap |
8952 | @cindex keyboard | |
b3d05f48 | 8953 | @deffn {Scheme Procedure} console-keymap-service @var{files} ... |
dedb8d5e | 8954 | @cindex keyboard layout |
b3d05f48 AK |
8955 | Return a service to load console keymaps from @var{files} using |
8956 | @command{loadkeys} command. Most likely, you want to load some default | |
8957 | keymap, which can be done like this: | |
8958 | ||
8959 | @example | |
8960 | (console-keymap-service "dvorak") | |
8961 | @end example | |
8962 | ||
8963 | Or, for example, for a Swedish keyboard, you may need to combine | |
8964 | the following keymaps: | |
8965 | @example | |
8966 | (console-keymap-service "se-lat6" "se-fi-lat6") | |
8967 | @end example | |
8968 | ||
8969 | Also you can specify a full file name (or file names) of your keymap(s). | |
8970 | See @code{man loadkeys} for details. | |
8971 | ||
5eca9459 AK |
8972 | @end deffn |
8973 | ||
e32171ee JD |
8974 | @cindex mouse |
8975 | @cindex gpm | |
1aaf116d | 8976 | @deffn {Scheme Procedure} gpm-service [#:gpm @var{gpm}] @ |
8664cc88 LC |
8977 | [#:options] |
8978 | Run @var{gpm}, the general-purpose mouse daemon, with the given | |
8979 | command-line @var{options}. GPM allows users to use the mouse in the console, | |
8980 | notably to select, copy, and paste text. The default value of @var{options} | |
8981 | uses the @code{ps2} protocol, which works for both USB and PS/2 mice. | |
8982 | ||
8983 | This service is not part of @var{%base-services}. | |
8984 | @end deffn | |
8985 | ||
1c52181f LC |
8986 | @anchor{guix-publish-service} |
8987 | @deffn {Scheme Procedure} guix-publish-service [#:guix @var{guix}] @ | |
8988 | [#:port 80] [#:host "localhost"] | |
8989 | Return a service that runs @command{guix publish} listening on @var{host} | |
8990 | and @var{port} (@pxref{Invoking guix publish}). | |
8991 | ||
8992 | This assumes that @file{/etc/guix} already contains a signing key pair as | |
8993 | created by @command{guix archive --generate-key} (@pxref{Invoking guix | |
8994 | archive}). If that is not the case, the service will fail to start. | |
8995 | @end deffn | |
8996 | ||
b58cbf9a DC |
8997 | @anchor{rngd-service} |
8998 | @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @ | |
8999 | [#:device "/dev/hwrng"] | |
9000 | Return a service that runs the @command{rngd} program from @var{rng-tools} | |
9001 | to add @var{device} to the kernel's entropy pool. The service will fail if | |
9002 | @var{device} does not exist. | |
9003 | @end deffn | |
a69576ea | 9004 | |
909147e4 RW |
9005 | @anchor{pam-limits-service} |
9006 | @cindex session limits | |
9007 | @cindex ulimit | |
9008 | @cindex priority | |
9009 | @deffn {Scheme Procedure} pam-limits-service [#:limits @var{limits}] | |
9010 | ||
9011 | Return a service that installs a configuration file for the | |
9012 | @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html, | |
9013 | @code{pam_limits} module}. The procedure optionally takes a list of | |
9014 | @code{pam-limits-entry} values, which can be used to specify | |
9015 | @code{ulimit} limits and nice priority limits to user sessions. | |
9016 | ||
9017 | The following limits definition sets two hard and soft limits for all | |
9018 | login sessions of users in the @code{realtime} group: | |
9019 | ||
9020 | @example | |
9021 | (pam-limits-service | |
9022 | (list | |
9023 | (pam-limits-entry "@@realtime" 'both 'rtprio 99) | |
9024 | (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited))) | |
9025 | @end example | |
9026 | ||
9027 | The first entry increases the maximum realtime priority for | |
9028 | non-privileged processes; the second entry lifts any restriction of the | |
9029 | maximum address space that can be locked in memory. These settings are | |
9030 | commonly used for real-time audio systems. | |
9031 | @end deffn | |
9032 | ||
c311089b LC |
9033 | @node Scheduled Job Execution |
9034 | @subsubsection Scheduled Job Execution | |
9035 | ||
9036 | @cindex cron | |
e32171ee | 9037 | @cindex mcron |
c311089b LC |
9038 | @cindex scheduling jobs |
9039 | The @code{(gnu services mcron)} module provides an interface to | |
9040 | GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,, | |
9041 | mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional | |
9042 | Unix @command{cron} daemon; the main difference is that it is | |
9043 | implemented in Guile Scheme, which provides a lot of flexibility when | |
9044 | specifying the scheduling of jobs and their actions. | |
9045 | ||
8ac6282c | 9046 | The example below defines an operating system that runs the |
c311089b | 9047 | @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files}) |
8ac6282c LC |
9048 | and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as |
9049 | well as the @command{mkid} command on behalf of an unprivileged user | |
9050 | (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses | |
9051 | gexps to introduce job definitions that are passed to mcron | |
9052 | (@pxref{G-Expressions}). | |
c311089b LC |
9053 | |
9054 | @lisp | |
9055 | (use-modules (guix) (gnu) (gnu services mcron)) | |
8ac6282c | 9056 | (use-package-modules base idutils) |
c311089b LC |
9057 | |
9058 | (define updatedb-job | |
8ac6282c LC |
9059 | ;; Run 'updatedb' at 3AM every day. Here we write the |
9060 | ;; job's action as a Scheme procedure. | |
c311089b | 9061 | #~(job '(next-hour '(3)) |
8ac6282c LC |
9062 | (lambda () |
9063 | (execl (string-append #$findutils "/bin/updatedb") | |
9064 | "updatedb" | |
9065 | "--prunepaths=/tmp /var/tmp /gnu/store")))) | |
c311089b LC |
9066 | |
9067 | (define garbage-collector-job | |
9068 | ;; Collect garbage 5 minutes after midnight every day. | |
8ac6282c | 9069 | ;; The job's action is a shell command. |
c311089b LC |
9070 | #~(job "5 0 * * *" ;Vixie cron syntax |
9071 | "guix gc -F 1G")) | |
9072 | ||
80d944b7 | 9073 | (define idutils-job |
8ac6282c LC |
9074 | ;; Update the index database as user "charlie" at 12:15PM |
9075 | ;; and 19:15PM. This runs from the user's home directory. | |
9076 | #~(job '(next-minute-from (next-hour '(12 19)) '(15)) | |
9077 | (string-append #$idutils "/bin/mkid src") | |
9078 | #:user "charlie")) | |
9079 | ||
c311089b LC |
9080 | (operating-system |
9081 | ;; @dots{} | |
9082 | (services (cons (mcron-service (list garbage-collector-job | |
8ac6282c LC |
9083 | updatedb-job |
9084 | idutils-job)) | |
c311089b LC |
9085 | %base-services))) |
9086 | @end lisp | |
9087 | ||
9088 | @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron}, | |
9089 | for more information on mcron job specifications. Below is the | |
9090 | reference of the mcron service. | |
9091 | ||
9092 | @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron2}] | |
9093 | Return an mcron service running @var{mcron} that schedules @var{jobs}, a | |
9094 | list of gexps denoting mcron job specifications. | |
9095 | ||
9096 | This is a shorthand for: | |
9097 | @example | |
80d944b7 LC |
9098 | (service mcron-service-type |
9099 | (mcron-configuration (mcron mcron) (jobs jobs))) | |
c311089b LC |
9100 | @end example |
9101 | @end deffn | |
9102 | ||
9103 | @defvr {Scheme Variable} mcron-service-type | |
9104 | This is the type of the @code{mcron} service, whose value is an | |
9105 | @code{mcron-configuration} object. | |
9106 | ||
9107 | This service type can be the target of a service extension that provides | |
9108 | it additional job specifications (@pxref{Service Composition}). In | |
80d944b7 | 9109 | other words, it is possible to define services that provide additional |
c311089b LC |
9110 | mcron jobs to run. |
9111 | @end defvr | |
9112 | ||
9113 | @deftp {Data Type} mcron-configuration | |
9114 | Data type representing the configuration of mcron. | |
9115 | ||
9116 | @table @asis | |
9117 | @item @code{mcron} (default: @var{mcron2}) | |
9118 | The mcron package to use. | |
9119 | ||
9120 | @item @code{jobs} | |
9121 | This is a list of gexps (@pxref{G-Expressions}), where each gexp | |
9122 | corresponds to an mcron job specification (@pxref{Syntax, mcron job | |
9123 | specifications,, mcron, GNU@tie{}mcron}). | |
9124 | @end table | |
9125 | @end deftp | |
9126 | ||
9127 | ||
92c03a87 JN |
9128 | @node Log Rotation |
9129 | @subsubsection Log Rotation | |
9130 | ||
9131 | @cindex rottlog | |
9132 | @cindex log rotation | |
e32171ee | 9133 | @cindex logging |
92c03a87 JN |
9134 | Log files such as those found in @file{/var/log} tend to grow endlessly, |
9135 | so it's a good idea to @dfn{rotate} them once in a while---i.e., archive | |
9136 | their contents in separate files, possibly compressed. The @code{(gnu | |
9137 | services admin)} module provides an interface to GNU@tie{}Rot[t]log, a | |
9138 | log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}). | |
9139 | ||
9140 | The example below defines an operating system that provides log rotation | |
9141 | with the default settings. | |
9142 | ||
9143 | @lisp | |
9144 | (use-modules (guix) (gnu)) | |
9145 | (use-service-modules admin mcron) | |
9146 | (use-package-modules base idutils) | |
9147 | ||
9148 | (operating-system | |
9149 | ;; @dots{} | |
9150 | (services (cons* (mcron-service) | |
9151 | (service rottlog-service-type (rottlog-configuration)) | |
9152 | %base-services))) | |
9153 | @end lisp | |
9154 | ||
9155 | @defvr {Scheme Variable} rottlog-service-type | |
9156 | This is the type of the Rottlog service, whose value is a | |
9157 | @code{rottlog-configuration} object. | |
9158 | ||
9159 | This service type can define mcron jobs (@pxref{Scheduled Job | |
9160 | Execution}) to run the rottlog service. | |
9161 | @end defvr | |
9162 | ||
9163 | @deftp {Data Type} rottlog-configuration | |
9164 | Data type representing the configuration of rottlog. | |
9165 | ||
9166 | @table @asis | |
9167 | @item @code{rottlog} (default: @code{rottlog}) | |
9168 | The Rottlog package to use. | |
9169 | ||
9170 | @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")}) | |
9171 | The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,, | |
9172 | rottlog, GNU Rot[t]log Manual}). | |
9173 | ||
9174 | @item @code{periodic-rotations} (default: @code{`(("weekly" %default-rotatations))}) | |
9175 | A list of Rottlog period-name/period-config tuples. | |
9176 | ||
9177 | For example, taking an example from the Rottlog manual (@pxref{Period | |
9178 | Related File Examples,,, rottlog, GNU Rot[t]log Manual}), a valid tuple | |
9179 | might be: | |
9180 | ||
9181 | @example | |
9182 | ("daily" ,(plain-file "daily" | |
9183 | "\ | |
9184 | /var/log/apache/* @{ | |
9185 | storedir apache-archives | |
9186 | rotate 6 | |
9187 | notifempty | |
9188 | nocompress | |
9189 | @}")) | |
9190 | @end example | |
9191 | ||
9192 | @item @code{jobs} | |
9193 | This is a list of gexps where each gexp corresponds to an mcron job | |
9194 | specification (@pxref{Scheduled Job Execution}). | |
9195 | @end table | |
9196 | @end deftp | |
9197 | ||
9198 | @defvr {Scheme Variable} %default-rotations | |
9199 | Specifies weekly rotation of @var{%rotated-files} and | |
9200 | @code{"/var/log/shepherd.log"}. | |
9201 | @end defvr | |
9202 | ||
9203 | @defvr {Scheme Variable} %rotated-files | |
9204 | The list of syslog-controlled files to be rotated. By default it is: | |
9205 | @code{'("/var/log/messages" "/var/log/secure")}. | |
9206 | @end defvr | |
9207 | ||
cf4a9129 LC |
9208 | @node Networking Services |
9209 | @subsubsection Networking Services | |
401c53c4 | 9210 | |
fa1e31b8 | 9211 | The @code{(gnu services networking)} module provides services to configure |
cf4a9129 | 9212 | the network interface. |
a1ba8475 | 9213 | |
a023cca8 | 9214 | @cindex DHCP, networking service |
be1c2c54 | 9215 | @deffn {Scheme Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}] |
a023cca8 LC |
9216 | Return a service that runs @var{dhcp}, a Dynamic Host Configuration |
9217 | Protocol (DHCP) client, on all the non-loopback network interfaces. | |
9218 | @end deffn | |
9219 | ||
8de3e4b3 LC |
9220 | @defvr {Scheme Variable} static-networking-service-type |
9221 | This is the type for statically-configured network interfaces. | |
9222 | @c TODO Document <static-networking> data structures. | |
9223 | @end defvr | |
9224 | ||
be1c2c54 | 9225 | @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @ |
1f9803c2 | 9226 | [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] |
cf4a9129 | 9227 | Return a service that starts @var{interface} with address @var{ip}. If |
1f9803c2 LC |
9228 | @var{netmask} is true, use it as the network mask. If @var{gateway} is true, |
9229 | it must be a string specifying the default network gateway. | |
8de3e4b3 LC |
9230 | |
9231 | This procedure can be called several times, one for each network | |
9232 | interface of interest. Behind the scenes what it does is extend | |
9233 | @code{static-networking-service-type} with additional network interfaces | |
9234 | to handle. | |
cf4a9129 | 9235 | @end deffn |
8b315a6d | 9236 | |
b7d0c494 | 9237 | @cindex wicd |
e32171ee JD |
9238 | @cindex wireless |
9239 | @cindex WiFi | |
87f40011 | 9240 | @cindex network management |
be1c2c54 | 9241 | @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}] |
87f40011 LC |
9242 | Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network |
9243 | management daemon that aims to simplify wired and wireless networking. | |
9244 | ||
9245 | This service adds the @var{wicd} package to the global profile, providing | |
9246 | several commands to interact with the daemon and configure networking: | |
9247 | @command{wicd-client}, a graphical user interface, and the @command{wicd-cli} | |
9248 | and @command{wicd-curses} user interfaces. | |
b7d0c494 MW |
9249 | @end deffn |
9250 | ||
c0a9589d | 9251 | @cindex NetworkManager |
b726096b CB |
9252 | |
9253 | @defvr {Scheme Variable} network-manager-service-type | |
9254 | This is the service type for the | |
9255 | @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager} | |
9256 | service. The value for this service type is a | |
9257 | @code{network-manager-configuration} record. | |
9258 | @end defvr | |
9259 | ||
9260 | @deftp {Data Type} network-manager-configuration | |
9261 | Data type representing the configuration of NetworkManager. | |
9262 | ||
9263 | @table @asis | |
9264 | @item @code{network-manager} (default: @code{network-manager}) | |
9265 | The NetworkManager package to use. | |
9266 | ||
9267 | @item @code{dns} (default: @code{"default"}) | |
9268 | Processing mode for DNS, which affects how NetworkManager uses the | |
9269 | @code{resolv.conf} configuration file. | |
9270 | ||
9271 | @table @samp | |
9272 | @item default | |
9273 | NetworkManager will update @code{resolv.conf} to reflect the nameservers | |
9274 | provided by currently active connections. | |
9275 | ||
9276 | @item dnsmasq | |
9277 | NetworkManager will run @code{dnsmasq} as a local caching nameserver, | |
9278 | using a "split DNS" configuration if you are connected to a VPN, and | |
9279 | then update @code{resolv.conf} to point to the local nameserver. | |
9280 | ||
9281 | @item none | |
9282 | NetworkManager will not modify @code{resolv.conf}. | |
9283 | @end table | |
9284 | ||
9285 | @end table | |
9286 | @end deftp | |
c0a9589d | 9287 | |
76192896 | 9288 | @cindex Connman |
34d60c49 MO |
9289 | @deffn {Scheme Variable} connman-service-type |
9290 | This is the service type to run @url{https://01.org/connman,Connman}, | |
9291 | a network connection manager. | |
9292 | ||
9293 | Its value must be an | |
9294 | @code{connman-configuration} record as in this example: | |
9295 | ||
9296 | @example | |
9297 | (service connman-service-type | |
9298 | (connman-configuration | |
9299 | (disable-vpn? #t))) | |
9300 | @end example | |
9301 | ||
9302 | See below for details about @code{connman-configuration}. | |
76192896 EF |
9303 | @end deffn |
9304 | ||
34d60c49 MO |
9305 | @deftp {Data Type} connman-configuration |
9306 | Data Type representing the configuration of connman. | |
9307 | ||
9308 | @table @asis | |
9309 | @item @code{connman} (default: @var{connman}) | |
9310 | The connman package to use. | |
9311 | ||
9312 | @item @code{disable-vpn?} (default: @code{#f}) | |
9313 | When true, enable connman's vpn plugin. | |
9314 | @end table | |
9315 | @end deftp | |
9316 | ||
2cccbc2a | 9317 | @cindex WPA Supplicant |
cbf1024e LC |
9318 | @defvr {Scheme Variable} wpa-supplicant-service-type |
9319 | This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA | |
2cccbc2a | 9320 | supplicant}, an authentication daemon required to authenticate against |
cbf1024e | 9321 | encrypted WiFi or ethernet networks. It is configured to listen for |
2cccbc2a | 9322 | requests on D-Bus. |
cbf1024e LC |
9323 | |
9324 | The value of this service is the @code{wpa-supplicant} package to use. | |
9325 | Thus, it can be instantiated like this: | |
9326 | ||
9327 | @lisp | |
9328 | (use-modules (gnu services networking) | |
9329 | (gnu packages admin)) | |
9330 | ||
9747d189 | 9331 | (service wpa-supplicant-service-type wpa-supplicant) |
cbf1024e LC |
9332 | @end lisp |
9333 | @end defvr | |
2cccbc2a | 9334 | |
e32171ee JD |
9335 | @cindex NTP |
9336 | @cindex real time clock | |
be1c2c54 | 9337 | @deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @ |
dc0322b5 LC |
9338 | [#:servers @var{%ntp-servers}] @ |
9339 | [#:allow-large-adjustment? #f] | |
63854bcb LC |
9340 | Return a service that runs the daemon from @var{ntp}, the |
9341 | @uref{http://www.ntp.org, Network Time Protocol package}. The daemon will | |
9342 | keep the system clock synchronized with that of @var{servers}. | |
dc0322b5 LC |
9343 | @var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to |
9344 | make an initial adjustment of more than 1,000 seconds. | |
63854bcb LC |
9345 | @end deffn |
9346 | ||
9347 | @defvr {Scheme Variable} %ntp-servers | |
9348 | List of host names used as the default NTP servers. | |
9349 | @end defvr | |
9350 | ||
e32171ee | 9351 | @cindex Tor |
375c6108 LC |
9352 | @deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}] |
9353 | Return a service to run the @uref{https://torproject.org, Tor} anonymous | |
9354 | networking daemon. | |
8b315a6d | 9355 | |
375c6108 | 9356 | The daemon runs as the @code{tor} unprivileged user. It is passed |
6331bde7 LC |
9357 | @var{config-file}, a file-like object, with an additional @code{User tor} line |
9358 | and lines for hidden services added via @code{tor-hidden-service}. Run | |
9359 | @command{man tor} for information about the configuration file. | |
9360 | @end deffn | |
9361 | ||
24a8ef3b | 9362 | @cindex hidden service |
6331bde7 LC |
9363 | @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping} |
9364 | Define a new Tor @dfn{hidden service} called @var{name} and implementing | |
9365 | @var{mapping}. @var{mapping} is a list of port/host tuples, such as: | |
9366 | ||
9367 | @example | |
24a8ef3b LC |
9368 | '((22 "127.0.0.1:22") |
9369 | (80 "127.0.0.1:8080")) | |
6331bde7 LC |
9370 | @end example |
9371 | ||
9372 | In this example, port 22 of the hidden service is mapped to local port 22, and | |
9373 | port 80 is mapped to local port 8080. | |
9374 | ||
6629099a LC |
9375 | This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where |
9376 | the @file{hostname} file contains the @code{.onion} host name for the hidden | |
6331bde7 LC |
9377 | service. |
9378 | ||
9379 | See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor | |
9380 | project's documentation} for more information. | |
cf4a9129 | 9381 | @end deffn |
8b315a6d | 9382 | |
be1c2c54 | 9383 | @deffn {Scheme Procedure} bitlbee-service [#:bitlbee bitlbee] @ |
4627a464 LC |
9384 | [#:interface "127.0.0.1"] [#:port 6667] @ |
9385 | [#:extra-settings ""] | |
9386 | Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that | |
9387 | acts as a gateway between IRC and chat networks. | |
9388 | ||
9389 | The daemon will listen to the interface corresponding to the IP address | |
9390 | specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only | |
9391 | local clients can connect, whereas @code{0.0.0.0} means that connections can | |
9392 | come from any networking interface. | |
9393 | ||
9394 | In addition, @var{extra-settings} specifies a string to append to the | |
9395 | configuration file. | |
9396 | @end deffn | |
9397 | ||
71b0601a | 9398 | Furthermore, @code{(gnu services ssh)} provides the following services. |
e32171ee JD |
9399 | @cindex SSH |
9400 | @cindex SSH server | |
8b315a6d | 9401 | |
be1c2c54 | 9402 | @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @ |
5833bf33 | 9403 | [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @ |
cf4a9129 LC |
9404 | [#:allow-empty-passwords? #f] [#:root-login? #f] @ |
9405 | [#:syslog-output? #t] [#:x11-forwarding? #t] @ | |
9406 | [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @ | |
21cc905a | 9407 | [#:public-key-authentication? #t] [#:initialize? #t] |
cf4a9129 LC |
9408 | Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}. |
9409 | @var{host-key} must designate a file containing the host key, and readable | |
9410 | only by root. | |
72e25e35 | 9411 | |
5833bf33 DP |
9412 | When @var{daemonic?} is true, @command{lshd} will detach from the |
9413 | controlling terminal and log its output to syslogd, unless one sets | |
9414 | @var{syslog-output?} to false. Obviously, it also makes lsh-service | |
9415 | depend on existence of syslogd service. When @var{pid-file?} is true, | |
9416 | @command{lshd} writes its PID to the file called @var{pid-file}. | |
9417 | ||
cf4a9129 LC |
9418 | When @var{initialize?} is true, automatically create the seed and host key |
9419 | upon service activation if they do not exist yet. This may take long and | |
9420 | require interaction. | |
8b315a6d | 9421 | |
20dd519c LC |
9422 | When @var{initialize?} is false, it is up to the user to initialize the |
9423 | randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create | |
9424 | a key pair with the private key stored in file @var{host-key} (@pxref{lshd | |
9425 | basics,,, lsh, LSH Manual}). | |
9426 | ||
cf4a9129 LC |
9427 | When @var{interfaces} is empty, lshd listens for connections on all the |
9428 | network interfaces; otherwise, @var{interfaces} must be a list of host names | |
9429 | or addresses. | |
9bf3c1a7 | 9430 | |
20dd519c LC |
9431 | @var{allow-empty-passwords?} specifies whether to accept log-ins with empty |
9432 | passwords, and @var{root-login?} specifies whether to accept log-ins as | |
cf4a9129 | 9433 | root. |
4af2447e | 9434 | |
cf4a9129 LC |
9435 | The other options should be self-descriptive. |
9436 | @end deffn | |
4af2447e | 9437 | |
e32171ee JD |
9438 | @cindex SSH |
9439 | @cindex SSH server | |
d8f31281 LC |
9440 | @deffn {Scheme Variable} openssh-service-type |
9441 | This is the type for the @uref{http://www.openssh.org, OpenSSH} secure | |
9442 | shell daemon, @command{sshd}. Its value must be an | |
9443 | @code{openssh-configuration} record as in this example: | |
9444 | ||
9445 | @example | |
9446 | (service openssh-service-type | |
9447 | (openssh-configuration | |
9448 | (x11-forwarding? #t) | |
9449 | (permit-root-login 'without-password))) | |
9450 | @end example | |
9451 | ||
9452 | See below for details about @code{openssh-configuration}. | |
86d8f6d3 JL |
9453 | @end deffn |
9454 | ||
d8f31281 LC |
9455 | @deftp {Data Type} openssh-configuration |
9456 | This is the configuration record for OpenSSH's @command{sshd}. | |
9457 | ||
9458 | @table @asis | |
9459 | @item @code{pid-file} (default: @code{"/var/run/sshd.pid"}) | |
9460 | Name of the file where @command{sshd} writes its PID. | |
9461 | ||
9462 | @item @code{port-number} (default: @code{22}) | |
9463 | TCP port on which @command{sshd} listens for incoming connections. | |
9464 | ||
9465 | @item @code{permit-root-login} (default: @code{#f}) | |
9466 | This field determines whether and when to allow logins as root. If | |
9467 | @code{#f}, root logins are disallowed; if @code{#t}, they are allowed. | |
9468 | If it's the symbol @code{'without-password}, then root logins are | |
9469 | permitted but not with password-based authentication. | |
9470 | ||
9471 | @item @code{allow-empty-passwords?} (default: @code{#f}) | |
9472 | When true, users with empty passwords may log in. When false, they may | |
9473 | not. | |
9474 | ||
9475 | @item @code{password-authentication?} (default: @code{#t}) | |
9476 | When true, users may log in with their password. When false, they have | |
9477 | other authentication methods. | |
9478 | ||
9479 | @item @code{public-key-authentication?} (default: @code{#t}) | |
9480 | When true, users may log in using public key authentication. When | |
9481 | false, users have to use other authentication method. | |
9482 | ||
9483 | Authorized public keys are stored in @file{~/.ssh/authorized_keys}. | |
9484 | This is used only by protocol version 2. | |
9485 | ||
d8f31281 LC |
9486 | @item @code{x11-forwarding?} (default: @code{#f}) |
9487 | When true, forwarding of X11 graphical client connections is | |
9488 | enabled---in other words, @command{ssh} options @option{-X} and | |
9489 | @option{-Y} will work. | |
9490 | ||
563c5d42 CL |
9491 | @item @code{challenge-response-authentication?} (default: @code{#f}) |
9492 | Specifies whether challenge response authentication is allowed (e.g. via | |
9493 | PAM). | |
9494 | ||
9495 | @item @code{use-pam?} (default: @code{#t}) | |
9496 | Enables the Pluggable Authentication Module interface. If set to | |
9497 | @code{#t}, this will enable PAM authentication using | |
9498 | @code{challenge-response-authentication?} and | |
9499 | @code{password-authentication?}, in addition to PAM account and session | |
9500 | module processing for all authentication types. | |
9501 | ||
9502 | Because PAM challenge response authentication usually serves an | |
9503 | equivalent role to password authentication, you should disable either | |
9504 | @code{challenge-response-authentication?} or | |
9505 | @code{password-authentication?}. | |
f895dce4 CL |
9506 | |
9507 | @item @code{print-last-log?} (default: @code{#t}) | |
9508 | Specifies whether @command{sshd} should print the date and time of the | |
9509 | last user login when a user logs in interactively. | |
d8f31281 LC |
9510 | @end table |
9511 | @end deftp | |
9512 | ||
71b0601a DC |
9513 | @deffn {Scheme Procedure} dropbear-service [@var{config}] |
9514 | Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH | |
9515 | daemon} with the given @var{config}, a @code{<dropbear-configuration>} | |
9516 | object. | |
9517 | ||
9518 | For example, to specify a Dropbear service listening on port 1234, add | |
9519 | this call to the operating system's @code{services} field: | |
9520 | ||
9521 | @example | |
9522 | (dropbear-service (dropbear-configuration | |
9523 | (port-number 1234))) | |
9524 | @end example | |
9525 | @end deffn | |
9526 | ||
9527 | @deftp {Data Type} dropbear-configuration | |
9528 | This data type represents the configuration of a Dropbear SSH daemon. | |
9529 | ||
9530 | @table @asis | |
9531 | @item @code{dropbear} (default: @var{dropbear}) | |
9532 | The Dropbear package to use. | |
9533 | ||
9534 | @item @code{port-number} (default: 22) | |
9535 | The TCP port where the daemon waits for incoming connections. | |
9536 | ||
9537 | @item @code{syslog-output?} (default: @code{#t}) | |
9538 | Whether to enable syslog output. | |
9539 | ||
9540 | @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"}) | |
9541 | File name of the daemon's PID file. | |
9542 | ||
9543 | @item @code{root-login?} (default: @code{#f}) | |
9544 | Whether to allow @code{root} logins. | |
9545 | ||
9546 | @item @code{allow-empty-passwords?} (default: @code{#f}) | |
9547 | Whether to allow empty passwords. | |
9548 | ||
9549 | @item @code{password-authentication?} (default: @code{#t}) | |
9550 | Whether to enable password-based authentication. | |
9551 | @end table | |
9552 | @end deftp | |
9553 | ||
fa0c1d61 LC |
9554 | @defvr {Scheme Variable} %facebook-host-aliases |
9555 | This variable contains a string for use in @file{/etc/hosts} | |
9556 | (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each | |
9557 | line contains a entry that maps a known server name of the Facebook | |
9558 | on-line service---e.g., @code{www.facebook.com}---to the local | |
9559 | host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}. | |
9560 | ||
9561 | This variable is typically used in the @code{hosts-file} field of an | |
7313a52e LC |
9562 | @code{operating-system} declaration (@pxref{operating-system Reference, |
9563 | @file{/etc/hosts}}): | |
fa0c1d61 LC |
9564 | |
9565 | @example | |
9566 | (use-modules (gnu) (guix)) | |
9567 | ||
9568 | (operating-system | |
9569 | (host-name "mymachine") | |
9570 | ;; ... | |
9571 | (hosts-file | |
9572 | ;; Create a /etc/hosts file with aliases for "localhost" | |
9573 | ;; and "mymachine", as well as for Facebook servers. | |
24e02c28 LC |
9574 | (plain-file "hosts" |
9575 | (string-append (local-host-aliases host-name) | |
9576 | %facebook-host-aliases)))) | |
fa0c1d61 LC |
9577 | @end example |
9578 | ||
9579 | This mechanism can prevent programs running locally, such as Web | |
9580 | browsers, from accessing Facebook. | |
9581 | @end defvr | |
9582 | ||
965a7332 LC |
9583 | The @code{(gnu services avahi)} provides the following definition. |
9584 | ||
be1c2c54 | 9585 | @deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @ |
965a7332 LC |
9586 | [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @ |
9587 | [#:ipv6? #t] [#:wide-area? #f] @ | |
c8695f32 | 9588 | [#:domains-to-browse '()] [#:debug? #f] |
965a7332 LC |
9589 | Return a service that runs @command{avahi-daemon}, a system-wide |
9590 | mDNS/DNS-SD responder that allows for service discovery and | |
cc9c1f39 LC |
9591 | "zero-configuration" host name lookups (see @uref{http://avahi.org/}), and |
9592 | extends the name service cache daemon (nscd) so that it can resolve | |
9593 | @code{.local} host names using | |
1065bed9 LC |
9594 | @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally, |
9595 | add the @var{avahi} package to the system profile so that commands such as | |
9596 | @command{avahi-browse} are directly usable. | |
965a7332 LC |
9597 | |
9598 | If @var{host-name} is different from @code{#f}, use that as the host name to | |
9599 | publish for this machine; otherwise, use the machine's actual host name. | |
9600 | ||
9601 | When @var{publish?} is true, publishing of host names and services is allowed; | |
9602 | in particular, avahi-daemon will publish the machine's host name and IP | |
9603 | address via mDNS on the local network. | |
9604 | ||
9605 | When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled. | |
9606 | ||
9607 | Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6 | |
9608 | sockets. | |
9609 | @end deffn | |
9610 | ||
c32d02fe SB |
9611 | @deffn {Scheme Variable} openvswitch-service-type |
9612 | This is the type of the @uref{http://www.openvswitch.org, Open vSwitch} | |
9613 | service, whose value should be an @code{openvswitch-configuration} | |
9614 | object. | |
9615 | @end deffn | |
9616 | ||
9617 | @deftp {Data Type} openvswitch-configuration | |
9618 | Data type representing the configuration of Open vSwitch, a multilayer | |
9619 | virtual switch which is designed to enable massive network automation | |
9620 | through programmatic extension. | |
9621 | ||
9622 | @table @asis | |
9623 | @item @code{package} (default: @var{openvswitch}) | |
9624 | Package object of the Open vSwitch. | |
9625 | ||
9626 | @end table | |
9627 | @end deftp | |
965a7332 | 9628 | |
cf4a9129 LC |
9629 | @node X Window |
9630 | @subsubsection X Window | |
68ad877c | 9631 | |
e32171ee JD |
9632 | @cindex X11 |
9633 | @cindex X Window System | |
cf4a9129 LC |
9634 | Support for the X Window graphical display system---specifically |
9635 | Xorg---is provided by the @code{(gnu services xorg)} module. Note that | |
9636 | there is no @code{xorg-service} procedure. Instead, the X server is | |
9637 | started by the @dfn{login manager}, currently SLiM. | |
4af2447e | 9638 | |
935644c0 DC |
9639 | @deftp {Data Type} sddm-configuration |
9640 | This is the data type representing the sddm service configuration. | |
9641 | ||
9642 | @table @asis | |
9643 | @item @code{display-server} (default: "x11") | |
9644 | Select display server to use for the greeter. Valid values are "x11" | |
9645 | or "wayland". | |
9646 | ||
9647 | @item @code{numlock} (default: "on") | |
9648 | Valid values are "on", "off" or "none". | |
9649 | ||
9650 | @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")}) | |
9651 | Command to run when halting. | |
9652 | ||
9653 | @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")}) | |
9654 | Command to run when rebooting. | |
9655 | ||
9656 | @item @code{theme} (default "maldives") | |
9657 | Theme to use. Default themes provided by SDDM are "elarun" or "maldives". | |
9658 | ||
9659 | @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes") | |
9660 | Directory to look for themes. | |
9661 | ||
9662 | @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces") | |
9663 | Directory to look for faces. | |
9664 | ||
9665 | @item @code{default-path} (default "/run/current-system/profile/bin") | |
9666 | Default PATH to use. | |
9667 | ||
9668 | @item @code{minimum-uid} (default 1000) | |
9669 | Minimum UID to display in SDDM. | |
9670 | ||
9671 | @item @code{maximum-uid} (default 2000) | |
9672 | Maximum UID to display in SDDM | |
9673 | ||
9674 | @item @code{remember-last-user?} (default #t) | |
9675 | Remember last user. | |
9676 | ||
9677 | @item @code{remember-last-session?} (default #t) | |
9678 | Remember last session. | |
9679 | ||
9680 | @item @code{hide-users} (default "") | |
9681 | Usernames to hide from SDDM greeter. | |
9682 | ||
9683 | @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")}) | |
9684 | Users with shells listed will be hidden from the SDDM greeter. | |
9685 | ||
9686 | @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")}) | |
9687 | Script to run before starting a wayland session. | |
9688 | ||
9689 | @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions") | |
9690 | Directory to look for desktop files starting wayland sessions. | |
9691 | ||
9692 | @item @code{xorg-server-path} (default @code{xorg-start-command}) | |
9693 | Path to xorg-server. | |
9694 | ||
9695 | @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")}) | |
9696 | Path to xauth. | |
9697 | ||
9698 | @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")}) | |
9699 | Path to Xephyr. | |
9700 | ||
9701 | @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")}) | |
9702 | Script to run after starting xorg-server. | |
9703 | ||
9704 | @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")}) | |
9705 | Script to run before stopping xorg-server. | |
9706 | ||
9707 | @item @code{xsession-command} (default: @code{xinitr }) | |
9708 | Script to run before starting a X session. | |
9709 | ||
9710 | @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions") | |
9711 | Directory to look for desktop files starting X sessions. | |
9712 | ||
9713 | @item @code{minimum-vt} (default: 7) | |
9714 | Minimum VT to use. | |
9715 | ||
9716 | @item @code{xserver-arguments} (default "-nolisten tcp") | |
9717 | Arguments to pass to xorg-server. | |
9718 | ||
9719 | @item @code{auto-login-user} (default "") | |
9720 | User to use for auto-login. | |
9721 | ||
9722 | @item @code{auto-login-session} (default "") | |
9723 | Desktop file to use for auto-login. | |
9724 | ||
9725 | @item @code{relogin?} (default #f) | |
9726 | Relogin after logout. | |
9727 | ||
9728 | @end table | |
9729 | @end deftp | |
9730 | ||
e32171ee | 9731 | @cindex login manager |
935644c0 DC |
9732 | @deffn {Scheme Procedure} sddm-service config |
9733 | Return a service that spawns the SDDM graphical login manager for config of | |
9734 | type @code{<sddm-configuration>}. | |
9735 | ||
9736 | @example | |
9737 | (sddm-service (sddm-configuration | |
9738 | (auto-login-user "Alice") | |
9739 | (auto-login-session "xfce.desktop"))) | |
9740 | @end example | |
9741 | @end deffn | |
9742 | ||
be1c2c54 | 9743 | @deffn {Scheme Procedure} slim-service [#:allow-empty-passwords? #f] @ |
0ecc3bf3 LC |
9744 | [#:auto-login? #f] [#:default-user ""] [#:startx] @ |
9745 | [#:theme @var{%default-slim-theme}] @ | |
4bd43bbe | 9746 | [#:theme-name @var{%default-slim-theme-name}] |
cf4a9129 LC |
9747 | Return a service that spawns the SLiM graphical login manager, which in |
9748 | turn starts the X display server with @var{startx}, a command as returned by | |
9749 | @code{xorg-start-command}. | |
4af2447e | 9750 | |
04e4e6ab LC |
9751 | @cindex X session |
9752 | ||
9753 | SLiM automatically looks for session types described by the @file{.desktop} | |
9754 | files in @file{/run/current-system/profile/share/xsessions} and allows users | |
9755 | to choose a session from the log-in screen using @kbd{F1}. Packages such as | |
9756 | @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files; | |
9757 | adding them to the system-wide set of packages automatically makes them | |
9758 | available at the log-in screen. | |
9759 | ||
9760 | In addition, @file{~/.xsession} files are honored. When available, | |
9761 | @file{~/.xsession} must be an executable that starts a window manager | |
9762 | and/or other X clients. | |
9763 | ||
cf4a9129 LC |
9764 | When @var{allow-empty-passwords?} is true, allow logins with an empty |
9765 | password. When @var{auto-login?} is true, log in automatically as | |
9766 | @var{default-user}. | |
0ecc3bf3 | 9767 | |
1068f26b | 9768 | If @var{theme} is @code{#f}, use the default log-in theme; otherwise |
0ecc3bf3 LC |
9769 | @var{theme} must be a gexp denoting the name of a directory containing the |
9770 | theme to use. In that case, @var{theme-name} specifies the name of the | |
9771 | theme. | |
cf4a9129 | 9772 | @end deffn |
4af2447e | 9773 | |
0ecc3bf3 LC |
9774 | @defvr {Scheme Variable} %default-theme |
9775 | @defvrx {Scheme Variable} %default-theme-name | |
9776 | The G-Expression denoting the default SLiM theme and its name. | |
9777 | @end defvr | |
9778 | ||
be1c2c54 | 9779 | @deffn {Scheme Procedure} xorg-start-command [#:guile] @ |
d1cdd7ba | 9780 | [#:configuration-file #f] [#:xorg-server @var{xorg-server}] |
f703413e | 9781 | Return a derivation that builds a @var{guile} script to start the X server |
d1cdd7ba LC |
9782 | from @var{xorg-server}. @var{configuration-file} is the server configuration |
9783 | file or a derivation that builds it; when omitted, the result of | |
9784 | @code{xorg-configuration-file} is used. | |
9785 | ||
9786 | Usually the X server is started by a login manager. | |
9787 | @end deffn | |
9788 | ||
be1c2c54 | 9789 | @deffn {Scheme Procedure} xorg-configuration-file @ |
12422c9d | 9790 | [#:drivers '()] [#:resolutions '()] [#:extra-config '()] |
d1cdd7ba LC |
9791 | Return a configuration file for the Xorg server containing search paths for |
9792 | all the common drivers. | |
f703413e LC |
9793 | |
9794 | @var{drivers} must be either the empty list, in which case Xorg chooses a | |
9795 | graphics driver automatically, or a list of driver names that will be tried in | |
d1cdd7ba | 9796 | this order---e.g., @code{(\"modesetting\" \"vesa\")}. |
d2e59637 LC |
9797 | |
9798 | Likewise, when @var{resolutions} is the empty list, Xorg chooses an | |
9799 | appropriate screen resolution; otherwise, it must be a list of | |
9800 | resolutions---e.g., @code{((1024 768) (640 480))}. | |
12422c9d LC |
9801 | |
9802 | Last, @var{extra-config} is a list of strings or objects appended to the | |
9803 | @code{text-file*} argument list. It is used to pass extra text to be added | |
9804 | verbatim to the configuration file. | |
f703413e | 9805 | @end deffn |
4af2447e | 9806 | |
6726282b LC |
9807 | @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{name}] |
9808 | Add @var{package}, a package for a screen-locker or screen-saver whose | |
9809 | command is @var{program}, to the set of setuid programs and add a PAM entry | |
9810 | for it. For example: | |
9811 | ||
9812 | @lisp | |
9813 | (screen-locker-service xlockmore "xlock") | |
9814 | @end lisp | |
9815 | ||
9816 | makes the good ol' XlockMore usable. | |
9817 | @end deffn | |
9818 | ||
9819 | ||
f2ec23d1 AW |
9820 | @node Printing Services |
9821 | @subsubsection Printing Services | |
9822 | ||
de322a5d | 9823 | @cindex printer support with CUPS |
f2ec23d1 AW |
9824 | The @code{(gnu services cups)} module provides a Guix service definition |
9825 | for the CUPS printing service. To add printer support to a GuixSD | |
9826 | system, add a @code{cups-service} to the operating system definition: | |
9827 | ||
9828 | @deffn {Scheme Variable} cups-service-type | |
9829 | The service type for the CUPS print server. Its value should be a valid | |
9830 | CUPS configuration (see below). For example: | |
9831 | @example | |
9832 | (service cups-service-type (cups-configuration)) | |
9833 | @end example | |
9834 | @end deffn | |
9835 | ||
9836 | The CUPS configuration controls the basic things about your CUPS | |
9837 | installation: what interfaces it listens on, what to do if a print job | |
9838 | fails, how much logging to do, and so on. To actually add a printer, | |
9839 | you have to visit the @url{http://localhost:631} URL, or use a tool such | |
9840 | as GNOME's printer configuration services. By default, configuring a | |
9841 | CUPS service will generate a self-signed certificate if needed, for | |
9842 | secure connections to the print server. | |
9843 | ||
de322a5d LC |
9844 | Suppose you want to enable the Web interface of CUPS and also add |
9845 | support for HP printers @i{via} the @code{hplip} package. You can do | |
9846 | that directly, like this (you need to use the @code{(gnu packages cups)} | |
9847 | module): | |
f2ec23d1 AW |
9848 | |
9849 | @example | |
9850 | (service cups-service-type | |
9851 | (cups-configuration | |
de322a5d LC |
9852 | (web-interface? #t) |
9853 | (extensions | |
9854 | (list cups-filters hplip)))) | |
f2ec23d1 AW |
9855 | @end example |
9856 | ||
9857 | The available configuration parameters follow. Each parameter | |
9858 | definition is preceded by its type; for example, @samp{string-list foo} | |
9859 | indicates that the @code{foo} parameter should be specified as a list of | |
9860 | strings. There is also a way to specify the configuration as a string, | |
9861 | if you have an old @code{cupsd.conf} file that you want to port over | |
9862 | from some other system; see the end for more details. | |
9863 | ||
9864 | @c The following documentation was initially generated by | |
9865 | @c (generate-documentation) in (gnu services cups). Manually maintained | |
9866 | @c documentation is better, so we shouldn't hesitate to edit below as | |
9867 | @c needed. However if the change you want to make to this documentation | |
9868 | @c can be done in an automated way, it's probably easier to change | |
9869 | @c (generate-documentation) than to make it below and have to deal with | |
9870 | @c the churn as CUPS updates. | |
9871 | ||
9872 | ||
9873 | Available @code{cups-configuration} fields are: | |
9874 | ||
9875 | @deftypevr {@code{cups-configuration} parameter} package cups | |
9876 | The CUPS package. | |
9877 | @end deftypevr | |
9878 | ||
9879 | @deftypevr {@code{cups-configuration} parameter} package-list extensions | |
9880 | Drivers and other extensions to the CUPS package. | |
9881 | @end deftypevr | |
9882 | ||
9883 | @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration | |
9884 | Configuration of where to write logs, what directories to use for print | |
9885 | spools, and related privileged configuration parameters. | |
9886 | ||
9887 | Available @code{files-configuration} fields are: | |
9888 | ||
9889 | @deftypevr {@code{files-configuration} parameter} log-location access-log | |
9890 | Defines the access log filename. Specifying a blank filename disables | |
9891 | access log generation. The value @code{stderr} causes log entries to be | |
9892 | sent to the standard error file when the scheduler is running in the | |
9893 | foreground, or to the system log daemon when run in the background. The | |
9894 | value @code{syslog} causes log entries to be sent to the system log | |
9895 | daemon. The server name may be included in filenames using the string | |
9896 | @code{%s}, as in @code{/var/log/cups/%s-access_log}. | |
9897 | ||
9898 | Defaults to @samp{"/var/log/cups/access_log"}. | |
9899 | @end deftypevr | |
9900 | ||
9901 | @deftypevr {@code{files-configuration} parameter} file-name cache-dir | |
9902 | Where CUPS should cache data. | |
9903 | ||
9904 | Defaults to @samp{"/var/cache/cups"}. | |
9905 | @end deftypevr | |
9906 | ||
9907 | @deftypevr {@code{files-configuration} parameter} string config-file-perm | |
9908 | Specifies the permissions for all configuration files that the scheduler | |
9909 | writes. | |
9910 | ||
9911 | Note that the permissions for the printers.conf file are currently | |
9912 | masked to only allow access from the scheduler user (typically root). | |
9913 | This is done because printer device URIs sometimes contain sensitive | |
9914 | authentication information that should not be generally known on the | |
9915 | system. There is no way to disable this security feature. | |
9916 | ||
9917 | Defaults to @samp{"0640"}. | |
9918 | @end deftypevr | |
9919 | ||
9920 | @deftypevr {@code{files-configuration} parameter} log-location error-log | |
9921 | Defines the error log filename. Specifying a blank filename disables | |
9922 | access log generation. The value @code{stderr} causes log entries to be | |
9923 | sent to the standard error file when the scheduler is running in the | |
9924 | foreground, or to the system log daemon when run in the background. The | |
9925 | value @code{syslog} causes log entries to be sent to the system log | |
9926 | daemon. The server name may be included in filenames using the string | |
9927 | @code{%s}, as in @code{/var/log/cups/%s-error_log}. | |
9928 | ||
9929 | Defaults to @samp{"/var/log/cups/error_log"}. | |
9930 | @end deftypevr | |
9931 | ||
9932 | @deftypevr {@code{files-configuration} parameter} string fatal-errors | |
9933 | Specifies which errors are fatal, causing the scheduler to exit. The | |
9934 | kind strings are: | |
9935 | ||
9936 | @table @code | |
9937 | @item none | |
9938 | No errors are fatal. | |
9939 | ||
9940 | @item all | |
9941 | All of the errors below are fatal. | |
9942 | ||
9943 | @item browse | |
9944 | Browsing initialization errors are fatal, for example failed connections | |
9945 | to the DNS-SD daemon. | |
9946 | ||
9947 | @item config | |
9948 | Configuration file syntax errors are fatal. | |
9949 | ||
9950 | @item listen | |
9951 | Listen or Port errors are fatal, except for IPv6 failures on the | |
9952 | loopback or @code{any} addresses. | |
9953 | ||
9954 | @item log | |
9955 | Log file creation or write errors are fatal. | |
9956 | ||
9957 | @item permissions | |
9958 | Bad startup file permissions are fatal, for example shared TLS | |
9959 | certificate and key files with world-read permissions. | |
9960 | @end table | |
9961 | ||
9962 | Defaults to @samp{"all -browse"}. | |
9963 | @end deftypevr | |
9964 | ||
9965 | @deftypevr {@code{files-configuration} parameter} boolean file-device? | |
9966 | Specifies whether the file pseudo-device can be used for new printer | |
9967 | queues. The URI @uref{file:///dev/null} is always allowed. | |
9968 | ||
9969 | Defaults to @samp{#f}. | |
9970 | @end deftypevr | |
9971 | ||
9972 | @deftypevr {@code{files-configuration} parameter} string group | |
9973 | Specifies the group name or ID that will be used when executing external | |
9974 | programs. | |
9975 | ||
9976 | Defaults to @samp{"lp"}. | |
9977 | @end deftypevr | |
9978 | ||
9979 | @deftypevr {@code{files-configuration} parameter} string log-file-perm | |
9980 | Specifies the permissions for all log files that the scheduler writes. | |
9981 | ||
9982 | Defaults to @samp{"0644"}. | |
9983 | @end deftypevr | |
9984 | ||
9985 | @deftypevr {@code{files-configuration} parameter} log-location page-log | |
9986 | Defines the page log filename. Specifying a blank filename disables | |
9987 | access log generation. The value @code{stderr} causes log entries to be | |
9988 | sent to the standard error file when the scheduler is running in the | |
9989 | foreground, or to the system log daemon when run in the background. The | |
9990 | value @code{syslog} causes log entries to be sent to the system log | |
9991 | daemon. The server name may be included in filenames using the string | |
9992 | @code{%s}, as in @code{/var/log/cups/%s-page_log}. | |
9993 | ||
9994 | Defaults to @samp{"/var/log/cups/page_log"}. | |
9995 | @end deftypevr | |
9996 | ||
9997 | @deftypevr {@code{files-configuration} parameter} string remote-root | |
9998 | Specifies the username that is associated with unauthenticated accesses | |
9999 | by clients claiming to be the root user. The default is @code{remroot}. | |
10000 | ||
10001 | Defaults to @samp{"remroot"}. | |
10002 | @end deftypevr | |
10003 | ||
10004 | @deftypevr {@code{files-configuration} parameter} file-name request-root | |
10005 | Specifies the directory that contains print jobs and other HTTP request | |
10006 | data. | |
10007 | ||
10008 | Defaults to @samp{"/var/spool/cups"}. | |
10009 | @end deftypevr | |
10010 | ||
10011 | @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing | |
10012 | Specifies the level of security sandboxing that is applied to print | |
10013 | filters, backends, and other child processes of the scheduler; either | |
10014 | @code{relaxed} or @code{strict}. This directive is currently only | |
10015 | used/supported on macOS. | |
10016 | ||
10017 | Defaults to @samp{strict}. | |
10018 | @end deftypevr | |
10019 | ||
10020 | @deftypevr {@code{files-configuration} parameter} file-name server-keychain | |
10021 | Specifies the location of TLS certificates and private keys. CUPS will | |
10022 | look for public and private keys in this directory: a @code{.crt} files | |
10023 | for PEM-encoded certificates and corresponding @code{.key} files for | |
10024 | PEM-encoded private keys. | |
10025 | ||
10026 | Defaults to @samp{"/etc/cups/ssl"}. | |
10027 | @end deftypevr | |
10028 | ||
10029 | @deftypevr {@code{files-configuration} parameter} file-name server-root | |
10030 | Specifies the directory containing the server configuration files. | |
10031 | ||
10032 | Defaults to @samp{"/etc/cups"}. | |
10033 | @end deftypevr | |
10034 | ||
10035 | @deftypevr {@code{files-configuration} parameter} boolean sync-on-close? | |
10036 | Specifies whether the scheduler calls fsync(2) after writing | |
10037 | configuration or state files. | |
10038 | ||
10039 | Defaults to @samp{#f}. | |
10040 | @end deftypevr | |
10041 | ||
10042 | @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group | |
10043 | Specifies the group(s) to use for @code{@@SYSTEM} group authentication. | |
10044 | @end deftypevr | |
10045 | ||
10046 | @deftypevr {@code{files-configuration} parameter} file-name temp-dir | |
10047 | Specifies the directory where temporary files are stored. | |
10048 | ||
10049 | Defaults to @samp{"/var/spool/cups/tmp"}. | |
10050 | @end deftypevr | |
10051 | ||
10052 | @deftypevr {@code{files-configuration} parameter} string user | |
10053 | Specifies the user name or ID that is used when running external | |
10054 | programs. | |
10055 | ||
10056 | Defaults to @samp{"lp"}. | |
10057 | @end deftypevr | |
10058 | @end deftypevr | |
10059 | ||
10060 | @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level | |
10061 | Specifies the logging level for the AccessLog file. The @code{config} | |
10062 | level logs when printers and classes are added, deleted, or modified and | |
10063 | when configuration files are accessed or updated. The @code{actions} | |
10064 | level logs when print jobs are submitted, held, released, modified, or | |
10065 | canceled, and any of the conditions for @code{config}. The @code{all} | |
10066 | level logs all requests. | |
10067 | ||
10068 | Defaults to @samp{actions}. | |
10069 | @end deftypevr | |
10070 | ||
10071 | @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs? | |
10072 | Specifies whether to purge job history data automatically when it is no | |
10073 | longer required for quotas. | |
10074 | ||
10075 | Defaults to @samp{#f}. | |
10076 | @end deftypevr | |
10077 | ||
10078 | @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols | |
10079 | Specifies which protocols to use for local printer sharing. | |
10080 | ||
10081 | Defaults to @samp{dnssd}. | |
10082 | @end deftypevr | |
10083 | ||
10084 | @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if? | |
10085 | Specifies whether the CUPS web interface is advertised. | |
10086 | ||
10087 | Defaults to @samp{#f}. | |
10088 | @end deftypevr | |
10089 | ||
10090 | @deftypevr {@code{cups-configuration} parameter} boolean browsing? | |
10091 | Specifies whether shared printers are advertised. | |
10092 | ||
10093 | Defaults to @samp{#f}. | |
10094 | @end deftypevr | |
10095 | ||
10096 | @deftypevr {@code{cups-configuration} parameter} string classification | |
10097 | Specifies the security classification of the server. Any valid banner | |
10098 | name can be used, including "classified", "confidential", "secret", | |
10099 | "topsecret", and "unclassified", or the banner can be omitted to disable | |
10100 | secure printing functions. | |
10101 | ||
10102 | Defaults to @samp{""}. | |
10103 | @end deftypevr | |
10104 | ||
10105 | @deftypevr {@code{cups-configuration} parameter} boolean classify-override? | |
10106 | Specifies whether users may override the classification (cover page) of | |
10107 | individual print jobs using the @code{job-sheets} option. | |
10108 | ||
10109 | Defaults to @samp{#f}. | |
10110 | @end deftypevr | |
10111 | ||
10112 | @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type | |
10113 | Specifies the default type of authentication to use. | |
10114 | ||
10115 | Defaults to @samp{Basic}. | |
10116 | @end deftypevr | |
10117 | ||
10118 | @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption | |
10119 | Specifies whether encryption will be used for authenticated requests. | |
10120 | ||
10121 | Defaults to @samp{Required}. | |
10122 | @end deftypevr | |
10123 | ||
10124 | @deftypevr {@code{cups-configuration} parameter} string default-language | |
10125 | Specifies the default language to use for text and web content. | |
10126 | ||
10127 | Defaults to @samp{"en"}. | |
10128 | @end deftypevr | |
10129 | ||
10130 | @deftypevr {@code{cups-configuration} parameter} string default-paper-size | |
10131 | Specifies the default paper size for new print queues. @samp{"Auto"} | |
10132 | uses a locale-specific default, while @samp{"None"} specifies there is | |
10133 | no default paper size. Specific size names are typically | |
10134 | @samp{"Letter"} or @samp{"A4"}. | |
10135 | ||
10136 | Defaults to @samp{"Auto"}. | |
10137 | @end deftypevr | |
10138 | ||
10139 | @deftypevr {@code{cups-configuration} parameter} string default-policy | |
10140 | Specifies the default access policy to use. | |
10141 | ||
10142 | Defaults to @samp{"default"}. | |
10143 | @end deftypevr | |
10144 | ||
10145 | @deftypevr {@code{cups-configuration} parameter} boolean default-shared? | |
10146 | Specifies whether local printers are shared by default. | |
10147 | ||
10148 | Defaults to @samp{#t}. | |
10149 | @end deftypevr | |
10150 | ||
10151 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval | |
10152 | Specifies the delay for updating of configuration and state files, in | |
10153 | seconds. A value of 0 causes the update to happen as soon as possible, | |
10154 | typically within a few milliseconds. | |
10155 | ||
10156 | Defaults to @samp{30}. | |
10157 | @end deftypevr | |
10158 | ||
10159 | @deftypevr {@code{cups-configuration} parameter} error-policy error-policy | |
10160 | Specifies what to do when an error occurs. Possible values are | |
10161 | @code{abort-job}, which will discard the failed print job; | |
10162 | @code{retry-job}, which will retry the job at a later time; | |
10163 | @code{retry-this-job}, which retries the failed job immediately; and | |
10164 | @code{stop-printer}, which stops the printer. | |
10165 | ||
10166 | Defaults to @samp{stop-printer}. | |
10167 | @end deftypevr | |
10168 | ||
10169 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit | |
10170 | Specifies the maximum cost of filters that are run concurrently, which | |
10171 | can be used to minimize disk, memory, and CPU resource problems. A | |
10172 | limit of 0 disables filter limiting. An average print to a | |
10173 | non-PostScript printer needs a filter limit of about 200. A PostScript | |
10174 | printer needs about half that (100). Setting the limit below these | |
10175 | thresholds will effectively limit the scheduler to printing a single job | |
10176 | at any time. | |
10177 | ||
10178 | Defaults to @samp{0}. | |
10179 | @end deftypevr | |
10180 | ||
10181 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice | |
10182 | Specifies the scheduling priority of filters that are run to print a | |
10183 | job. The nice value ranges from 0, the highest priority, to 19, the | |
10184 | lowest priority. | |
10185 | ||
10186 | Defaults to @samp{0}. | |
10187 | @end deftypevr | |
10188 | ||
10189 | @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups | |
10190 | Specifies whether to do reverse lookups on connecting clients. The | |
10191 | @code{double} setting causes @code{cupsd} to verify that the hostname | |
10192 | resolved from the address matches one of the addresses returned for that | |
10193 | hostname. Double lookups also prevent clients with unregistered | |
10194 | addresses from connecting to your server. Only set this option to | |
10195 | @code{#t} or @code{double} if absolutely required. | |
10196 | ||
10197 | Defaults to @samp{#f}. | |
10198 | @end deftypevr | |
10199 | ||
10200 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay | |
10201 | Specifies the number of seconds to wait before killing the filters and | |
10202 | backend associated with a canceled or held job. | |
10203 | ||
10204 | Defaults to @samp{30}. | |
10205 | @end deftypevr | |
10206 | ||
10207 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval | |
10208 | Specifies the interval between retries of jobs in seconds. This is | |
10209 | typically used for fax queues but can also be used with normal print | |
10210 | queues whose error policy is @code{retry-job} or | |
10211 | @code{retry-current-job}. | |
10212 | ||
10213 | Defaults to @samp{30}. | |
10214 | @end deftypevr | |
10215 | ||
10216 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit | |
10217 | Specifies the number of retries that are done for jobs. This is | |
10218 | typically used for fax queues but can also be used with normal print | |
10219 | queues whose error policy is @code{retry-job} or | |
10220 | @code{retry-current-job}. | |
10221 | ||
10222 | Defaults to @samp{5}. | |
10223 | @end deftypevr | |
10224 | ||
10225 | @deftypevr {@code{cups-configuration} parameter} boolean keep-alive? | |
10226 | Specifies whether to support HTTP keep-alive connections. | |
10227 | ||
10228 | Defaults to @samp{#t}. | |
10229 | @end deftypevr | |
10230 | ||
10231 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout | |
10232 | Specifies how long an idle client connection remains open, in seconds. | |
10233 | ||
10234 | Defaults to @samp{30}. | |
10235 | @end deftypevr | |
10236 | ||
10237 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body | |
10238 | Specifies the maximum size of print files, IPP requests, and HTML form | |
10239 | data. A limit of 0 disables the limit check. | |
10240 | ||
10241 | Defaults to @samp{0}. | |
10242 | @end deftypevr | |
10243 | ||
10244 | @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen | |
10245 | Listens on the specified interfaces for connections. Valid values are | |
10246 | of the form @var{address}:@var{port}, where @var{address} is either an | |
10247 | IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to | |
10248 | indicate all addresses. Values can also be file names of local UNIX | |
10249 | domain sockets. The Listen directive is similar to the Port directive | |
10250 | but allows you to restrict access to specific interfaces or networks. | |
10251 | @end deftypevr | |
10252 | ||
10253 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log | |
10254 | Specifies the number of pending connections that will be allowed. This | |
10255 | normally only affects very busy servers that have reached the MaxClients | |
10256 | limit, but can also be triggered by large numbers of simultaneous | |
10257 | connections. When the limit is reached, the operating system will | |
10258 | refuse additional connections until the scheduler can accept the pending | |
10259 | ones. | |
10260 | ||
10261 | Defaults to @samp{128}. | |
10262 | @end deftypevr | |
10263 | ||
10264 | @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls | |
10265 | Specifies a set of additional access controls. | |
10266 | ||
10267 | Available @code{location-access-controls} fields are: | |
10268 | ||
10269 | @deftypevr {@code{location-access-controls} parameter} file-name path | |
10270 | Specifies the URI path to which the access control applies. | |
10271 | @end deftypevr | |
10272 | ||
10273 | @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls | |
10274 | Access controls for all access to this path, in the same format as the | |
10275 | @code{access-controls} of @code{operation-access-control}. | |
10276 | ||
10277 | Defaults to @samp{()}. | |
10278 | @end deftypevr | |
10279 | ||
10280 | @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls | |
10281 | Access controls for method-specific access to this path. | |
10282 | ||
10283 | Defaults to @samp{()}. | |
10284 | ||
10285 | Available @code{method-access-controls} fields are: | |
10286 | ||
10287 | @deftypevr {@code{method-access-controls} parameter} boolean reverse? | |
10288 | If @code{#t}, apply access controls to all methods except the listed | |
10289 | methods. Otherwise apply to only the listed methods. | |
10290 | ||
10291 | Defaults to @samp{#f}. | |
10292 | @end deftypevr | |
10293 | ||
10294 | @deftypevr {@code{method-access-controls} parameter} method-list methods | |
10295 | Methods to which this access control applies. | |
10296 | ||
10297 | Defaults to @samp{()}. | |
10298 | @end deftypevr | |
10299 | ||
10300 | @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls | |
10301 | Access control directives, as a list of strings. Each string should be | |
10302 | one directive, such as "Order allow,deny". | |
10303 | ||
10304 | Defaults to @samp{()}. | |
10305 | @end deftypevr | |
10306 | @end deftypevr | |
10307 | @end deftypevr | |
10308 | ||
10309 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history | |
10310 | Specifies the number of debugging messages that are retained for logging | |
10311 | if an error occurs in a print job. Debug messages are logged regardless | |
10312 | of the LogLevel setting. | |
10313 | ||
10314 | Defaults to @samp{100}. | |
10315 | @end deftypevr | |
10316 | ||
10317 | @deftypevr {@code{cups-configuration} parameter} log-level log-level | |
10318 | Specifies the level of logging for the ErrorLog file. The value | |
10319 | @code{none} stops all logging while @code{debug2} logs everything. | |
10320 | ||
10321 | Defaults to @samp{info}. | |
10322 | @end deftypevr | |
10323 | ||
10324 | @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format | |
10325 | Specifies the format of the date and time in the log files. The value | |
10326 | @code{standard} logs whole seconds while @code{usecs} logs microseconds. | |
10327 | ||
10328 | Defaults to @samp{standard}. | |
10329 | @end deftypevr | |
10330 | ||
10331 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients | |
10332 | Specifies the maximum number of simultaneous clients that are allowed by | |
10333 | the scheduler. | |
10334 | ||
10335 | Defaults to @samp{100}. | |
10336 | @end deftypevr | |
10337 | ||
10338 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host | |
10339 | Specifies the maximum number of simultaneous clients that are allowed | |
10340 | from a single address. | |
10341 | ||
10342 | Defaults to @samp{100}. | |
10343 | @end deftypevr | |
10344 | ||
10345 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies | |
10346 | Specifies the maximum number of copies that a user can print of each | |
10347 | job. | |
10348 | ||
10349 | Defaults to @samp{9999}. | |
10350 | @end deftypevr | |
10351 | ||
10352 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time | |
10353 | Specifies the maximum time a job may remain in the @code{indefinite} | |
10354 | hold state before it is canceled. A value of 0 disables cancellation of | |
10355 | held jobs. | |
10356 | ||
10357 | Defaults to @samp{0}. | |
10358 | @end deftypevr | |
10359 | ||
10360 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs | |
10361 | Specifies the maximum number of simultaneous jobs that are allowed. Set | |
10362 | to 0 to allow an unlimited number of jobs. | |
10363 | ||
10364 | Defaults to @samp{500}. | |
10365 | @end deftypevr | |
10366 | ||
10367 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer | |
10368 | Specifies the maximum number of simultaneous jobs that are allowed per | |
10369 | printer. A value of 0 allows up to MaxJobs jobs per printer. | |
10370 | ||
10371 | Defaults to @samp{0}. | |
10372 | @end deftypevr | |
10373 | ||
10374 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user | |
10375 | Specifies the maximum number of simultaneous jobs that are allowed per | |
10376 | user. A value of 0 allows up to MaxJobs jobs per user. | |
10377 | ||
10378 | Defaults to @samp{0}. | |
10379 | @end deftypevr | |
10380 | ||
10381 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time | |
10382 | Specifies the maximum time a job may take to print before it is | |
10383 | canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs. | |
10384 | ||
10385 | Defaults to @samp{10800}. | |
10386 | @end deftypevr | |
10387 | ||
10388 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size | |
10389 | Specifies the maximum size of the log files before they are rotated, in | |
10390 | bytes. The value 0 disables log rotation. | |
10391 | ||
10392 | Defaults to @samp{1048576}. | |
10393 | @end deftypevr | |
10394 | ||
10395 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout | |
10396 | Specifies the maximum amount of time to allow between files in a | |
10397 | multiple file print job, in seconds. | |
10398 | ||
10399 | Defaults to @samp{300}. | |
10400 | @end deftypevr | |
10401 | ||
10402 | @deftypevr {@code{cups-configuration} parameter} string page-log-format | |
10403 | Specifies the format of PageLog lines. Sequences beginning with percent | |
10404 | (@samp{%}) characters are replaced with the corresponding information, | |
10405 | while all other characters are copied literally. The following percent | |
10406 | sequences are recognized: | |
10407 | ||
10408 | @table @samp | |
10409 | @item %% | |
10410 | insert a single percent character | |
10411 | ||
10412 | @item %@{name@} | |
10413 | insert the value of the specified IPP attribute | |
10414 | ||
10415 | @item %C | |
10416 | insert the number of copies for the current page | |
10417 | ||
10418 | @item %P | |
10419 | insert the current page number | |
10420 | ||
10421 | @item %T | |
10422 | insert the current date and time in common log format | |
10423 | ||
10424 | @item %j | |
10425 | insert the job ID | |
10426 | ||
10427 | @item %p | |
10428 | insert the printer name | |
10429 | ||
10430 | @item %u | |
10431 | insert the username | |
10432 | @end table | |
10433 | ||
10434 | A value of the empty string disables page logging. The string @code{%p | |
10435 | %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@} | |
10436 | %@{job-name@} %@{media@} %@{sides@}} creates a page log with the | |
10437 | standard items. | |
10438 | ||
10439 | Defaults to @samp{""}. | |
10440 | @end deftypevr | |
10441 | ||
10442 | @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables | |
10443 | Passes the specified environment variable(s) to child processes; a list | |
10444 | of strings. | |
10445 | ||
10446 | Defaults to @samp{()}. | |
10447 | @end deftypevr | |
10448 | ||
10449 | @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies | |
10450 | Specifies named access control policies. | |
10451 | ||
10452 | Available @code{policy-configuration} fields are: | |
10453 | ||
10454 | @deftypevr {@code{policy-configuration} parameter} string name | |
10455 | Name of the policy. | |
10456 | @end deftypevr | |
10457 | ||
10458 | @deftypevr {@code{policy-configuration} parameter} string job-private-access | |
10459 | Specifies an access list for a job's private values. @code{@@ACL} maps | |
10460 | to the printer's requesting-user-name-allowed or | |
10461 | requesting-user-name-denied values. @code{@@OWNER} maps to the job's | |
10462 | owner. @code{@@SYSTEM} maps to the groups listed for the | |
10463 | @code{system-group} field of the @code{files-config} configuration, | |
10464 | which is reified into the @code{cups-files.conf(5)} file. Other | |
10465 | possible elements of the access list include specific user names, and | |
10466 | @code{@@@var{group}} to indicate members of a specific group. The | |
10467 | access list may also be simply @code{all} or @code{default}. | |
10468 | ||
10469 | Defaults to @samp{"@@OWNER @@SYSTEM"}. | |
10470 | @end deftypevr | |
10471 | ||
10472 | @deftypevr {@code{policy-configuration} parameter} string job-private-values | |
10473 | Specifies the list of job values to make private, or @code{all}, | |
10474 | @code{default}, or @code{none}. | |
10475 | ||
10476 | Defaults to @samp{"job-name job-originating-host-name | |
10477 | job-originating-user-name phone"}. | |
10478 | @end deftypevr | |
10479 | ||
10480 | @deftypevr {@code{policy-configuration} parameter} string subscription-private-access | |
10481 | Specifies an access list for a subscription's private values. | |
10482 | @code{@@ACL} maps to the printer's requesting-user-name-allowed or | |
10483 | requesting-user-name-denied values. @code{@@OWNER} maps to the job's | |
10484 | owner. @code{@@SYSTEM} maps to the groups listed for the | |
10485 | @code{system-group} field of the @code{files-config} configuration, | |
10486 | which is reified into the @code{cups-files.conf(5)} file. Other | |
10487 | possible elements of the access list include specific user names, and | |
10488 | @code{@@@var{group}} to indicate members of a specific group. The | |
10489 | access list may also be simply @code{all} or @code{default}. | |
10490 | ||
10491 | Defaults to @samp{"@@OWNER @@SYSTEM"}. | |
10492 | @end deftypevr | |
10493 | ||
10494 | @deftypevr {@code{policy-configuration} parameter} string subscription-private-values | |
10495 | Specifies the list of job values to make private, or @code{all}, | |
10496 | @code{default}, or @code{none}. | |
10497 | ||
10498 | Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri | |
10499 | notify-subscriber-user-name notify-user-data"}. | |
10500 | @end deftypevr | |
10501 | ||
10502 | @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls | |
10503 | Access control by IPP operation. | |
10504 | ||
10505 | Defaults to @samp{()}. | |
10506 | @end deftypevr | |
10507 | @end deftypevr | |
10508 | ||
10509 | @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files | |
10510 | Specifies whether job files (documents) are preserved after a job is | |
10511 | printed. If a numeric value is specified, job files are preserved for | |
10512 | the indicated number of seconds after printing. Otherwise a boolean | |
10513 | value applies indefinitely. | |
10514 | ||
10515 | Defaults to @samp{86400}. | |
10516 | @end deftypevr | |
10517 | ||
10518 | @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history | |
10519 | Specifies whether the job history is preserved after a job is printed. | |
10520 | If a numeric value is specified, the job history is preserved for the | |
10521 | indicated number of seconds after printing. If @code{#t}, the job | |
10522 | history is preserved until the MaxJobs limit is reached. | |
10523 | ||
10524 | Defaults to @samp{#t}. | |
10525 | @end deftypevr | |
10526 | ||
10527 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout | |
10528 | Specifies the amount of time to wait for job completion before | |
10529 | restarting the scheduler. | |
10530 | ||
10531 | Defaults to @samp{30}. | |
10532 | @end deftypevr | |
10533 | ||
10534 | @deftypevr {@code{cups-configuration} parameter} string rip-cache | |
10535 | Specifies the maximum amount of memory to use when converting documents | |
10536 | into bitmaps for a printer. | |
10537 | ||
10538 | Defaults to @samp{"128m"}. | |
10539 | @end deftypevr | |
10540 | ||
10541 | @deftypevr {@code{cups-configuration} parameter} string server-admin | |
10542 | Specifies the email address of the server administrator. | |
10543 | ||
10544 | Defaults to @samp{"root@@localhost.localdomain"}. | |
10545 | @end deftypevr | |
10546 | ||
10547 | @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias | |
10548 | The ServerAlias directive is used for HTTP Host header validation when | |
10549 | clients connect to the scheduler from external interfaces. Using the | |
10550 | special name @code{*} can expose your system to known browser-based DNS | |
10551 | rebinding attacks, even when accessing sites through a firewall. If the | |
10552 | auto-discovery of alternate names does not work, we recommend listing | |
10553 | each alternate name with a ServerAlias directive instead of using | |
10554 | @code{*}. | |
10555 | ||
10556 | Defaults to @samp{*}. | |
10557 | @end deftypevr | |
10558 | ||
10559 | @deftypevr {@code{cups-configuration} parameter} string server-name | |
10560 | Specifies the fully-qualified host name of the server. | |
10561 | ||
10562 | Defaults to @samp{"localhost"}. | |
10563 | @end deftypevr | |
10564 | ||
10565 | @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens | |
10566 | Specifies what information is included in the Server header of HTTP | |
10567 | responses. @code{None} disables the Server header. @code{ProductOnly} | |
10568 | reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor} | |
10569 | reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}. | |
10570 | @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is | |
10571 | the output of the @code{uname} command. @code{Full} reports @code{CUPS | |
10572 | 2.0.0 (@var{uname}) IPP/2.0}. | |
10573 | ||
10574 | Defaults to @samp{Minimal}. | |
10575 | @end deftypevr | |
10576 | ||
10577 | @deftypevr {@code{cups-configuration} parameter} string set-env | |
10578 | Set the specified environment variable to be passed to child processes. | |
10579 | ||
10580 | Defaults to @samp{"variable value"}. | |
10581 | @end deftypevr | |
10582 | ||
10583 | @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen | |
10584 | Listens on the specified interfaces for encrypted connections. Valid | |
10585 | values are of the form @var{address}:@var{port}, where @var{address} is | |
10586 | either an IPv6 address enclosed in brackets, an IPv4 address, or | |
10587 | @code{*} to indicate all addresses. | |
10588 | ||
10589 | Defaults to @samp{()}. | |
10590 | @end deftypevr | |
10591 | ||
10592 | @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options | |
10593 | Sets encryption options. By default, CUPS only supports encryption | |
10594 | using TLS v1.0 or higher using known secure cipher suites. The | |
10595 | @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are | |
10596 | required for some older clients that do not implement newer ones. The | |
10597 | @code{AllowSSL3} option enables SSL v3.0, which is required for some | |
10598 | older clients that do not support TLS v1.0. | |
10599 | ||
10600 | Defaults to @samp{()}. | |
10601 | @end deftypevr | |
10602 | ||
10603 | @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance? | |
10604 | Specifies whether the scheduler requires clients to strictly adhere to | |
10605 | the IPP specifications. | |
10606 | ||
10607 | Defaults to @samp{#f}. | |
10608 | @end deftypevr | |
10609 | ||
10610 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout | |
10611 | Specifies the HTTP request timeout, in seconds. | |
10612 | ||
10613 | Defaults to @samp{300}. | |
10614 | ||
10615 | @end deftypevr | |
10616 | ||
10617 | @deftypevr {@code{cups-configuration} parameter} boolean web-interface? | |
10618 | Specifies whether the web interface is enabled. | |
10619 | ||
10620 | Defaults to @samp{#f}. | |
10621 | @end deftypevr | |
10622 | ||
10623 | At this point you're probably thinking ``oh dear, Guix manual, I like | |
10624 | you but you can stop already with the configuration options''. Indeed. | |
10625 | However, one more point: it could be that you have an existing | |
10626 | @code{cupsd.conf} that you want to use. In that case, you can pass an | |
10627 | @code{opaque-cups-configuration} as the configuration of a | |
10628 | @code{cups-service-type}. | |
10629 | ||
10630 | Available @code{opaque-cups-configuration} fields are: | |
10631 | ||
10632 | @deftypevr {@code{opaque-cups-configuration} parameter} package cups | |
10633 | The CUPS package. | |
10634 | @end deftypevr | |
10635 | ||
10636 | @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf | |
10637 | The contents of the @code{cupsd.conf}, as a string. | |
10638 | @end deftypevr | |
10639 | ||
10640 | @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf | |
10641 | The contents of the @code{cups-files.conf} file, as a string. | |
10642 | @end deftypevr | |
10643 | ||
10644 | For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in | |
10645 | strings of the same name, you could instantiate a CUPS service like | |
10646 | this: | |
10647 | ||
10648 | @example | |
10649 | (service cups-service-type | |
10650 | (opaque-cups-configuration | |
10651 | (cupsd.conf cupsd.conf) | |
10652 | (cups-files.conf cups-files.conf))) | |
10653 | @end example | |
10654 | ||
10655 | ||
fe1a39d3 LC |
10656 | @node Desktop Services |
10657 | @subsubsection Desktop Services | |
aa4ed923 | 10658 | |
fe1a39d3 LC |
10659 | The @code{(gnu services desktop)} module provides services that are |
10660 | usually useful in the context of a ``desktop'' setup---that is, on a | |
10661 | machine running a graphical display server, possibly with graphical user | |
7a2413e4 AW |
10662 | interfaces, etc. It also defines services that provide specific desktop |
10663 | environments like GNOME and XFCE. | |
aa4ed923 | 10664 | |
4467be21 LC |
10665 | To simplify things, the module defines a variable containing the set of |
10666 | services that users typically expect on a machine with a graphical | |
10667 | environment and networking: | |
10668 | ||
10669 | @defvr {Scheme Variable} %desktop-services | |
10670 | This is a list of services that builds upon @var{%base-services} and | |
1068f26b | 10671 | adds or adjusts services for a typical ``desktop'' setup. |
4467be21 LC |
10672 | |
10673 | In particular, it adds a graphical login manager (@pxref{X Window, | |
6726282b LC |
10674 | @code{slim-service}}), screen lockers, |
10675 | a network management tool (@pxref{Networking | |
4467be21 | 10676 | Services, @code{wicd-service}}), energy and color management services, |
4650a77e | 10677 | the @code{elogind} login and seat manager, the Polkit privilege service, |
cee32ee4 AW |
10678 | the GeoClue location service, an NTP client (@pxref{Networking |
10679 | Services}), the Avahi daemon, and has the name service switch service | |
10680 | configured to be able to use @code{nss-mdns} (@pxref{Name Service | |
10681 | Switch, mDNS}). | |
4467be21 LC |
10682 | @end defvr |
10683 | ||
10684 | The @var{%desktop-services} variable can be used as the @code{services} | |
10685 | field of an @code{operating-system} declaration (@pxref{operating-system | |
10686 | Reference, @code{services}}). | |
10687 | ||
7a2413e4 AW |
10688 | Additionally, the @code{gnome-desktop-service} and |
10689 | @code{xfce-desktop-service} procedures can add GNOME and/or XFCE to a | |
10690 | system. To ``add GNOME'' means that system-level services like the | |
10691 | backlight adjustment helpers and the power management utilities are | |
10692 | added to the system, extending @code{polkit} and @code{dbus} | |
10693 | appropriately, allowing GNOME to operate with elevated privileges on a | |
10694 | limited number of special-purpose system interfaces. Additionally, | |
10695 | adding a service made by @code{gnome-desktop-service} adds the GNOME | |
10696 | metapackage to the system profile. Likewise, adding the XFCE service | |
10697 | not only adds the @code{xfce} metapackage to the system profile, but it | |
10698 | also gives the Thunar file manager the ability to open a ``root-mode'' | |
10699 | file management window, if the user authenticates using the | |
10700 | administrator's password via the standard polkit graphical interface. | |
10701 | ||
10702 | @deffn {Scheme Procedure} gnome-desktop-service | |
10703 | Return a service that adds the @code{gnome} package to the system | |
10704 | profile, and extends polkit with the actions from | |
10705 | @code{gnome-settings-daemon}. | |
10706 | @end deffn | |
10707 | ||
10708 | @deffn {Scheme Procedure} xfce-desktop-service | |
10709 | Return a service that adds the @code{xfce} package to the system profile, | |
5741e3e5 | 10710 | and extends polkit with the ability for @code{thunar} to manipulate the |
7a2413e4 AW |
10711 | file system as root from within a user session, after the user has |
10712 | authenticated with the administrator's password. | |
10713 | @end deffn | |
10714 | ||
10715 | Because the GNOME and XFCE desktop services pull in so many packages, | |
10716 | the default @code{%desktop-services} variable doesn't include either of | |
10717 | them by default. To add GNOME or XFCE, just @code{cons} them onto | |
10718 | @code{%desktop-services} in the @code{services} field of your | |
10719 | @code{operating-system}: | |
10720 | ||
10721 | @example | |
10722 | (use-modules (gnu)) | |
10723 | (use-service-modules desktop) | |
10724 | (operating-system | |
10725 | ... | |
10726 | ;; cons* adds items to the list given as its last argument. | |
10727 | (services (cons* (gnome-desktop-service) | |
10728 | (xfce-desktop-service) | |
10729 | %desktop-services)) | |
10730 | ...) | |
10731 | @end example | |
10732 | ||
10733 | These desktop environments will then be available as options in the | |
10734 | graphical login window. | |
10735 | ||
10736 | The actual service definitions included in @code{%desktop-services} and | |
10737 | provided by @code{(gnu services dbus)} and @code{(gnu services desktop)} | |
10738 | are described below. | |
4467be21 | 10739 | |
0adfe95a | 10740 | @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()] |
fe1a39d3 LC |
10741 | Return a service that runs the ``system bus'', using @var{dbus}, with |
10742 | support for @var{services}. | |
aa4ed923 | 10743 | |
fe1a39d3 LC |
10744 | @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication |
10745 | facility. Its system bus is used to allow system services to communicate | |
1068f26b | 10746 | and to be notified of system-wide events. |
aa4ed923 | 10747 | |
fe1a39d3 LC |
10748 | @var{services} must be a list of packages that provide an |
10749 | @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration | |
10750 | and policy files. For example, to allow avahi-daemon to use the system bus, | |
10751 | @var{services} must be equal to @code{(list avahi)}. | |
aa4ed923 AK |
10752 | @end deffn |
10753 | ||
0adfe95a | 10754 | @deffn {Scheme Procedure} elogind-service [#:config @var{config}] |
4650a77e AW |
10755 | Return a service that runs the @code{elogind} login and |
10756 | seat management daemon. @uref{https://github.com/andywingo/elogind, | |
10757 | Elogind} exposes a D-Bus interface that can be used to know which users | |
10758 | are logged in, know what kind of sessions they have open, suspend the | |
10759 | system, inhibit system suspend, reboot the system, and other tasks. | |
10760 | ||
10761 | Elogind handles most system-level power events for a computer, for | |
10762 | example suspending the system when a lid is closed, or shutting it down | |
10763 | when the power button is pressed. | |
10764 | ||
10765 | The @var{config} keyword argument specifies the configuration for | |
1068f26b | 10766 | elogind, and should be the result of an @code{(elogind-configuration |
4650a77e AW |
10767 | (@var{parameter} @var{value})...)} invocation. Available parameters and |
10768 | their default values are: | |
10769 | ||
10770 | @table @code | |
10771 | @item kill-user-processes? | |
10772 | @code{#f} | |
10773 | @item kill-only-users | |
10774 | @code{()} | |
10775 | @item kill-exclude-users | |
10776 | @code{("root")} | |
10777 | @item inhibit-delay-max-seconds | |
10778 | @code{5} | |
10779 | @item handle-power-key | |
10780 | @code{poweroff} | |
10781 | @item handle-suspend-key | |
10782 | @code{suspend} | |
10783 | @item handle-hibernate-key | |
10784 | @code{hibernate} | |
10785 | @item handle-lid-switch | |
10786 | @code{suspend} | |
10787 | @item handle-lid-switch-docked | |
10788 | @code{ignore} | |
10789 | @item power-key-ignore-inhibited? | |
10790 | @code{#f} | |
10791 | @item suspend-key-ignore-inhibited? | |
10792 | @code{#f} | |
10793 | @item hibernate-key-ignore-inhibited? | |
10794 | @code{#f} | |
10795 | @item lid-switch-ignore-inhibited? | |
10796 | @code{#t} | |
10797 | @item holdoff-timeout-seconds | |
10798 | @code{30} | |
10799 | @item idle-action | |
10800 | @code{ignore} | |
10801 | @item idle-action-seconds | |
10802 | @code{(* 30 60)} | |
10803 | @item runtime-directory-size-percent | |
10804 | @code{10} | |
10805 | @item runtime-directory-size | |
10806 | @code{#f} | |
10807 | @item remove-ipc? | |
10808 | @code{#t} | |
10809 | @item suspend-state | |
10810 | @code{("mem" "standby" "freeze")} | |
10811 | @item suspend-mode | |
10812 | @code{()} | |
10813 | @item hibernate-state | |
10814 | @code{("disk")} | |
10815 | @item hibernate-mode | |
10816 | @code{("platform" "shutdown")} | |
10817 | @item hybrid-sleep-state | |
10818 | @code{("disk")} | |
10819 | @item hybrid-sleep-mode | |
10820 | @code{("suspend" "platform" "shutdown")} | |
10821 | @end table | |
10822 | @end deffn | |
10823 | ||
be1c2c54 | 10824 | @deffn {Scheme Procedure} polkit-service @ |
4650a77e | 10825 | [#:polkit @var{polkit}] |
222e3319 LC |
10826 | Return a service that runs the |
10827 | @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege | |
10828 | management service}, which allows system administrators to grant access to | |
10829 | privileged operations in a structured way. By querying the Polkit service, a | |
10830 | privileged system component can know when it should grant additional | |
10831 | capabilities to ordinary users. For example, an ordinary user can be granted | |
10832 | the capability to suspend the system if the user is logged in locally. | |
4650a77e AW |
10833 | @end deffn |
10834 | ||
be1c2c54 | 10835 | @deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @ |
be234128 AW |
10836 | [#:watts-up-pro? #f] @ |
10837 | [#:poll-batteries? #t] @ | |
10838 | [#:ignore-lid? #f] @ | |
10839 | [#:use-percentage-for-policy? #f] @ | |
10840 | [#:percentage-low 10] @ | |
10841 | [#:percentage-critical 3] @ | |
10842 | [#:percentage-action 2] @ | |
10843 | [#:time-low 1200] @ | |
10844 | [#:time-critical 300] @ | |
10845 | [#:time-action 120] @ | |
10846 | [#:critical-power-action 'hybrid-sleep] | |
10847 | Return a service that runs @uref{http://upower.freedesktop.org/, | |
10848 | @command{upowerd}}, a system-wide monitor for power consumption and battery | |
10849 | levels, with the given configuration settings. It implements the | |
10850 | @code{org.freedesktop.UPower} D-Bus interface, and is notably used by | |
10851 | GNOME. | |
10852 | @end deffn | |
10853 | ||
2b9e0a94 LC |
10854 | @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}] |
10855 | Return a service for @uref{http://udisks.freedesktop.org/docs/latest/, | |
10856 | UDisks}, a @dfn{disk management} daemon that provides user interfaces with | |
10857 | notifications and ways to mount/unmount disks. Programs that talk to UDisks | |
10858 | include the @command{udisksctl} command, part of UDisks, and GNOME Disks. | |
10859 | @end deffn | |
10860 | ||
be1c2c54 | 10861 | @deffn {Scheme Procedure} colord-service [#:colord @var{colord}] |
7ce597ff AW |
10862 | Return a service that runs @command{colord}, a system service with a D-Bus |
10863 | interface to manage the color profiles of input and output devices such as | |
10864 | screens and scanners. It is notably used by the GNOME Color Manager graphical | |
10865 | tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web | |
10866 | site} for more information. | |
10867 | @end deffn | |
10868 | ||
cee32ee4 | 10869 | @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()] |
1068f26b | 10870 | Return a configuration allowing an application to access GeoClue |
cee32ee4 AW |
10871 | location data. @var{name} is the Desktop ID of the application, without |
10872 | the @code{.desktop} part. If @var{allowed?} is true, the application | |
10873 | will have access to location information by default. The boolean | |
1068f26b | 10874 | @var{system?} value indicates whether an application is a system component |
cee32ee4 AW |
10875 | or not. Finally @var{users} is a list of UIDs of all users for which |
10876 | this application is allowed location info access. An empty users list | |
10877 | means that all users are allowed. | |
10878 | @end deffn | |
10879 | ||
10880 | @defvr {Scheme Variable} %standard-geoclue-applications | |
10881 | The standard list of well-known GeoClue application configurations, | |
1068f26b AE |
10882 | granting authority to the GNOME date-and-time utility to ask for the |
10883 | current location in order to set the time zone, and allowing the | |
10884 | IceCat and Epiphany web browsers to request location information. | |
10885 | IceCat and Epiphany both query the user before allowing a web page to | |
cee32ee4 AW |
10886 | know the user's location. |
10887 | @end defvr | |
10888 | ||
be1c2c54 | 10889 | @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @ |
cee32ee4 AW |
10890 | [#:whitelist '()] @ |
10891 | [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @ | |
10892 | [#:submit-data? #f] | |
10893 | [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @ | |
10894 | [#:submission-nick "geoclue"] @ | |
10895 | [#:applications %standard-geoclue-applications] | |
10896 | Return a service that runs the GeoClue location service. This service | |
10897 | provides a D-Bus interface to allow applications to request access to a | |
10898 | user's physical location, and optionally to add information to online | |
10899 | location databases. See | |
10900 | @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue | |
10901 | web site} for more information. | |
10902 | @end deffn | |
10903 | ||
922e21f4 SB |
10904 | @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] |
10905 | Return a service that runs the @command{bluetoothd} daemon, which manages | |
10906 | all the Bluetooth devices and provides a number of D-Bus interfaces. | |
10907 | ||
10908 | Users need to be in the @code{lp} group to access the D-Bus service. | |
10909 | @end deffn | |
10910 | ||
105369a4 DT |
10911 | @node Database Services |
10912 | @subsubsection Database Services | |
10913 | ||
e32171ee JD |
10914 | @cindex database |
10915 | @cindex SQL | |
6575183b | 10916 | The @code{(gnu services databases)} module provides the following services. |
105369a4 | 10917 | |
be1c2c54 | 10918 | @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @ |
2d3d5cc5 | 10919 | [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @ |
e05b780a | 10920 | [#:port 5432] [#:locale ``en_US.utf8''] |
105369a4 DT |
10921 | Return a service that runs @var{postgresql}, the PostgreSQL database |
10922 | server. | |
10923 | ||
e05b780a CB |
10924 | The PostgreSQL daemon loads its runtime configuration from @var{config-file}, |
10925 | creates a database cluster with @var{locale} as the default | |
10926 | locale, stored in @var{data-directory}. It then listens on @var{port}. | |
105369a4 | 10927 | @end deffn |
fe1a39d3 | 10928 | |
6575183b SB |
10929 | @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)] |
10930 | Return a service that runs @command{mysqld}, the MySQL or MariaDB | |
10931 | database server. | |
10932 | ||
10933 | The optional @var{config} argument specifies the configuration for | |
c940b8e6 | 10934 | @command{mysqld}, which should be a @code{<mysql-configuration>} object. |
6575183b SB |
10935 | @end deffn |
10936 | ||
10937 | @deftp {Data Type} mysql-configuration | |
10938 | Data type representing the configuration of @var{mysql-service}. | |
10939 | ||
10940 | @table @asis | |
10941 | @item @code{mysql} (default: @var{mariadb}) | |
10942 | Package object of the MySQL database server, can be either @var{mariadb} | |
10943 | or @var{mysql}. | |
10944 | ||
7414de0a | 10945 | For MySQL, a temporary root password will be displayed at activation time. |
6575183b | 10946 | For MariaDB, the root password is empty. |
4b41febf CB |
10947 | |
10948 | @item @code{port} (default: @code{3306}) | |
10949 | TCP port on which the database server listens for incoming connections. | |
6575183b SB |
10950 | @end table |
10951 | @end deftp | |
10952 | ||
67cadaca CB |
10953 | @defvr {Scheme Variable} redis-service-type |
10954 | This is the service type for the @uref{https://redis.io/, Redis} | |
10955 | key/value store, whose value is a @code{redis-configuration} object. | |
10956 | @end defvr | |
10957 | ||
10958 | @deftp {Data Type} redis-configuration | |
10959 | Data type representing the configuration of redis. | |
10960 | ||
10961 | @table @asis | |
10962 | @item @code{redis} (default: @code{redis}) | |
10963 | The Redis package to use. | |
10964 | ||
10965 | @item @code{bind} (default: @code{"127.0.0.1"}) | |
10966 | Network interface on which to listen. | |
10967 | ||
10968 | @item @code{port} (default: @code{6379}) | |
10969 | Port on which to accept connections on, a value of 0 will disable | |
10970 | listining on a TCP socket. | |
10971 | ||
10972 | @item @code{working-directory} (default: @code{"/var/lib/redis"}) | |
10973 | Directory in which to store the database and related files. | |
10974 | @end table | |
10975 | @end deftp | |
10976 | ||
d8c18af8 AW |
10977 | @node Mail Services |
10978 | @subsubsection Mail Services | |
10979 | ||
e32171ee JD |
10980 | @cindex mail |
10981 | @cindex email | |
d8c18af8 | 10982 | The @code{(gnu services mail)} module provides Guix service definitions |
f88371e8 SB |
10983 | for email services: IMAP, POP3, and LMTP servers, as well as mail |
10984 | transport agents (MTAs). Lots of acronyms! These services are detailed | |
10985 | in the subsections below. | |
d8c18af8 | 10986 | |
f88371e8 | 10987 | @subsubheading Dovecot Service |
d8c18af8 AW |
10988 | |
10989 | @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)] | |
10990 | Return a service that runs the Dovecot IMAP/POP3/LMTP mail server. | |
10991 | @end deffn | |
10992 | ||
1068f26b | 10993 | By default, Dovecot does not need much configuration; the default |
d8c18af8 AW |
10994 | configuration object created by @code{(dovecot-configuration)} will |
10995 | suffice if your mail is delivered to @code{~/Maildir}. A self-signed | |
10996 | certificate will be generated for TLS-protected connections, though | |
10997 | Dovecot will also listen on cleartext ports by default. There are a | |
1068f26b | 10998 | number of options, though, which mail administrators might need to change, |
d8c18af8 AW |
10999 | and as is the case with other services, Guix allows the system |
11000 | administrator to specify these parameters via a uniform Scheme interface. | |
11001 | ||
11002 | For example, to specify that mail is located at @code{maildir~/.mail}, | |
11003 | one would instantiate the Dovecot service like this: | |
11004 | ||
11005 | @example | |
11006 | (dovecot-service #:config | |
11007 | (dovecot-configuration | |
11008 | (mail-location "maildir:~/.mail"))) | |
11009 | @end example | |
11010 | ||
11011 | The available configuration parameters follow. Each parameter | |
11012 | definition is preceded by its type; for example, @samp{string-list foo} | |
11013 | indicates that the @code{foo} parameter should be specified as a list of | |
11014 | strings. There is also a way to specify the configuration as a string, | |
11015 | if you have an old @code{dovecot.conf} file that you want to port over | |
11016 | from some other system; see the end for more details. | |
11017 | ||
11018 | @c The following documentation was initially generated by | |
11019 | @c (generate-documentation) in (gnu services mail). Manually maintained | |
11020 | @c documentation is better, so we shouldn't hesitate to edit below as | |
11021 | @c needed. However if the change you want to make to this documentation | |
11022 | @c can be done in an automated way, it's probably easier to change | |
11023 | @c (generate-documentation) than to make it below and have to deal with | |
11024 | @c the churn as dovecot updates. | |
11025 | ||
11026 | Available @code{dovecot-configuration} fields are: | |
11027 | ||
11028 | @deftypevr {@code{dovecot-configuration} parameter} package dovecot | |
11029 | The dovecot package. | |
11030 | @end deftypevr | |
11031 | ||
11032 | @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen | |
1068f26b AE |
11033 | A list of IPs or hosts where to listen for connections. @samp{*} |
11034 | listens on all IPv4 interfaces, @samp{::} listens on all IPv6 | |
d8c18af8 AW |
11035 | interfaces. If you want to specify non-default ports or anything more |
11036 | complex, customize the address and port fields of the | |
11037 | @samp{inet-listener} of the specific services you are interested in. | |
11038 | @end deftypevr | |
11039 | ||
11040 | @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols | |
11041 | List of protocols we want to serve. Available protocols include | |
11042 | @samp{imap}, @samp{pop3}, and @samp{lmtp}. | |
11043 | ||
11044 | Available @code{protocol-configuration} fields are: | |
11045 | ||
11046 | @deftypevr {@code{protocol-configuration} parameter} string name | |
11047 | The name of the protocol. | |
11048 | @end deftypevr | |
11049 | ||
11050 | @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path | |
1068f26b | 11051 | UNIX socket path to the master authentication server to find users. |
d8c18af8 | 11052 | This is used by imap (for shared users) and lda. |
1068f26b | 11053 | It defaults to @samp{"/var/run/dovecot/auth-userdb"}. |
d8c18af8 AW |
11054 | @end deftypevr |
11055 | ||
11056 | @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins | |
11057 | Space separated list of plugins to load. | |
11058 | @end deftypevr | |
11059 | ||
11060 | @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections | |
11061 | Maximum number of IMAP connections allowed for a user from each IP | |
11062 | address. NOTE: The username is compared case-sensitively. | |
11063 | Defaults to @samp{10}. | |
11064 | @end deftypevr | |
11065 | ||
11066 | @end deftypevr | |
11067 | ||
11068 | @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services | |
11069 | List of services to enable. Available services include @samp{imap}, | |
11070 | @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and | |
11071 | @samp{lmtp}. | |
11072 | ||
11073 | Available @code{service-configuration} fields are: | |
11074 | ||
11075 | @deftypevr {@code{service-configuration} parameter} string kind | |
11076 | The service kind. Valid values include @code{director}, | |
11077 | @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap}, | |
11078 | @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict}, | |
11079 | @code{tcpwrap}, @code{quota-warning}, or anything else. | |
11080 | @end deftypevr | |
11081 | ||
11082 | @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners | |
1068f26b | 11083 | Listeners for the service. A listener is either a |
d8c18af8 AW |
11084 | @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or |
11085 | an @code{inet-listener-configuration}. | |
11086 | Defaults to @samp{()}. | |
11087 | ||
11088 | Available @code{unix-listener-configuration} fields are: | |
11089 | ||
eba56076 CL |
11090 | @deftypevr {@code{unix-listener-configuration} parameter} string path |
11091 | Path to the file, relative to @code{base-dir} field. This is also used as | |
11092 | the section name. | |
d8c18af8 AW |
11093 | @end deftypevr |
11094 | ||
11095 | @deftypevr {@code{unix-listener-configuration} parameter} string mode | |
11096 | The access mode for the socket. | |
11097 | Defaults to @samp{"0600"}. | |
11098 | @end deftypevr | |
11099 | ||
11100 | @deftypevr {@code{unix-listener-configuration} parameter} string user | |
f9b9a033 | 11101 | The user to own the socket. |
d8c18af8 AW |
11102 | Defaults to @samp{""}. |
11103 | @end deftypevr | |
11104 | ||
11105 | @deftypevr {@code{unix-listener-configuration} parameter} string group | |
11106 | The group to own the socket. | |
11107 | Defaults to @samp{""}. | |
11108 | @end deftypevr | |
11109 | ||
11110 | ||
11111 | Available @code{fifo-listener-configuration} fields are: | |
11112 | ||
eba56076 CL |
11113 | @deftypevr {@code{fifo-listener-configuration} parameter} string path |
11114 | Path to the file, relative to @code{base-dir} field. This is also used as | |
11115 | the section name. | |
d8c18af8 AW |
11116 | @end deftypevr |
11117 | ||
11118 | @deftypevr {@code{fifo-listener-configuration} parameter} string mode | |
11119 | The access mode for the socket. | |
11120 | Defaults to @samp{"0600"}. | |
11121 | @end deftypevr | |
11122 | ||
11123 | @deftypevr {@code{fifo-listener-configuration} parameter} string user | |
f9b9a033 | 11124 | The user to own the socket. |
d8c18af8 AW |
11125 | Defaults to @samp{""}. |
11126 | @end deftypevr | |
11127 | ||
11128 | @deftypevr {@code{fifo-listener-configuration} parameter} string group | |
11129 | The group to own the socket. | |
11130 | Defaults to @samp{""}. | |
11131 | @end deftypevr | |
11132 | ||
11133 | ||
11134 | Available @code{inet-listener-configuration} fields are: | |
11135 | ||
11136 | @deftypevr {@code{inet-listener-configuration} parameter} string protocol | |
11137 | The protocol to listen for. | |
11138 | @end deftypevr | |
11139 | ||
11140 | @deftypevr {@code{inet-listener-configuration} parameter} string address | |
11141 | The address on which to listen, or empty for all addresses. | |
11142 | Defaults to @samp{""}. | |
11143 | @end deftypevr | |
11144 | ||
11145 | @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port | |
11146 | The port on which to listen. | |
11147 | @end deftypevr | |
11148 | ||
11149 | @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl? | |
11150 | Whether to use SSL for this service; @samp{yes}, @samp{no}, or | |
11151 | @samp{required}. | |
11152 | Defaults to @samp{#t}. | |
11153 | @end deftypevr | |
11154 | ||
11155 | @end deftypevr | |
11156 | ||
11157 | @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count | |
11158 | Number of connections to handle before starting a new process. | |
11159 | Typically the only useful values are 0 (unlimited) or 1. 1 is more | |
11160 | secure, but 0 is faster. <doc/wiki/LoginProcess.txt>. | |
11161 | Defaults to @samp{1}. | |
11162 | @end deftypevr | |
11163 | ||
11164 | @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail | |
11165 | Number of processes to always keep waiting for more connections. | |
11166 | Defaults to @samp{0}. | |
11167 | @end deftypevr | |
11168 | ||
11169 | @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit | |
11170 | If you set @samp{service-count 0}, you probably need to grow | |
11171 | this. | |
11172 | Defaults to @samp{256000000}. | |
11173 | @end deftypevr | |
11174 | ||
11175 | @end deftypevr | |
11176 | ||
11177 | @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict | |
11178 | Dict configuration, as created by the @code{dict-configuration} | |
11179 | constructor. | |
11180 | ||
11181 | Available @code{dict-configuration} fields are: | |
11182 | ||
11183 | @deftypevr {@code{dict-configuration} parameter} free-form-fields entries | |
11184 | A list of key-value pairs that this dict should hold. | |
11185 | Defaults to @samp{()}. | |
11186 | @end deftypevr | |
11187 | ||
11188 | @end deftypevr | |
11189 | ||
11190 | @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs | |
1068f26b | 11191 | A list of passdb configurations, each one created by the |
d8c18af8 AW |
11192 | @code{passdb-configuration} constructor. |
11193 | ||
11194 | Available @code{passdb-configuration} fields are: | |
11195 | ||
11196 | @deftypevr {@code{passdb-configuration} parameter} string driver | |
11197 | The driver that the passdb should use. Valid values include | |
11198 | @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and | |
11199 | @samp{static}. | |
11200 | Defaults to @samp{"pam"}. | |
11201 | @end deftypevr | |
11202 | ||
11203 | @deftypevr {@code{passdb-configuration} parameter} free-form-args args | |
11204 | A list of key-value args to the passdb driver. | |
11205 | Defaults to @samp{()}. | |
11206 | @end deftypevr | |
11207 | ||
11208 | @end deftypevr | |
11209 | ||
11210 | @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs | |
11211 | List of userdb configurations, each one created by the | |
11212 | @code{userdb-configuration} constructor. | |
11213 | ||
11214 | Available @code{userdb-configuration} fields are: | |
11215 | ||
11216 | @deftypevr {@code{userdb-configuration} parameter} string driver | |
11217 | The driver that the userdb should use. Valid values include | |
11218 | @samp{passwd} and @samp{static}. | |
11219 | Defaults to @samp{"passwd"}. | |
11220 | @end deftypevr | |
11221 | ||
11222 | @deftypevr {@code{userdb-configuration} parameter} free-form-args args | |
11223 | A list of key-value args to the userdb driver. | |
11224 | Defaults to @samp{()}. | |
11225 | @end deftypevr | |
11226 | ||
11227 | @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields | |
11228 | Override fields from passwd. | |
11229 | Defaults to @samp{()}. | |
11230 | @end deftypevr | |
11231 | ||
11232 | @end deftypevr | |
11233 | ||
11234 | @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration | |
11235 | Plug-in configuration, created by the @code{plugin-configuration} | |
11236 | constructor. | |
11237 | @end deftypevr | |
11238 | ||
11239 | @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces | |
11240 | List of namespaces. Each item in the list is created by the | |
11241 | @code{namespace-configuration} constructor. | |
11242 | ||
11243 | Available @code{namespace-configuration} fields are: | |
11244 | ||
11245 | @deftypevr {@code{namespace-configuration} parameter} string name | |
11246 | Name for this namespace. | |
11247 | @end deftypevr | |
11248 | ||
11249 | @deftypevr {@code{namespace-configuration} parameter} string type | |
11250 | Namespace type: @samp{private}, @samp{shared} or @samp{public}. | |
11251 | Defaults to @samp{"private"}. | |
11252 | @end deftypevr | |
11253 | ||
11254 | @deftypevr {@code{namespace-configuration} parameter} string separator | |
11255 | Hierarchy separator to use. You should use the same separator for | |
11256 | all namespaces or some clients get confused. @samp{/} is usually a good | |
11257 | one. The default however depends on the underlying mail storage | |
11258 | format. | |
11259 | Defaults to @samp{""}. | |
11260 | @end deftypevr | |
11261 | ||
11262 | @deftypevr {@code{namespace-configuration} parameter} string prefix | |
11263 | Prefix required to access this namespace. This needs to be | |
11264 | different for all namespaces. For example @samp{Public/}. | |
11265 | Defaults to @samp{""}. | |
11266 | @end deftypevr | |
11267 | ||
11268 | @deftypevr {@code{namespace-configuration} parameter} string location | |
1068f26b | 11269 | Physical location of the mailbox. This is in the same format as |
d8c18af8 AW |
11270 | mail_location, which is also the default for it. |
11271 | Defaults to @samp{""}. | |
11272 | @end deftypevr | |
11273 | ||
11274 | @deftypevr {@code{namespace-configuration} parameter} boolean inbox? | |
11275 | There can be only one INBOX, and this setting defines which | |
11276 | namespace has it. | |
11277 | Defaults to @samp{#f}. | |
11278 | @end deftypevr | |
11279 | ||
11280 | @deftypevr {@code{namespace-configuration} parameter} boolean hidden? | |
11281 | If namespace is hidden, it's not advertised to clients via NAMESPACE | |
11282 | extension. You'll most likely also want to set @samp{list? #f}. This is mostly | |
11283 | useful when converting from another server with different namespaces | |
11284 | which you want to deprecate but still keep working. For example you can | |
11285 | create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/} | |
11286 | and @samp{mail/}. | |
11287 | Defaults to @samp{#f}. | |
11288 | @end deftypevr | |
11289 | ||
11290 | @deftypevr {@code{namespace-configuration} parameter} boolean list? | |
1068f26b AE |
11291 | Show the mailboxes under this namespace with the LIST command. This |
11292 | makes the namespace visible for clients that do not support the NAMESPACE | |
d8c18af8 AW |
11293 | extension. The special @code{children} value lists child mailboxes, but |
11294 | hides the namespace prefix. | |
11295 | Defaults to @samp{#t}. | |
11296 | @end deftypevr | |
11297 | ||
11298 | @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions? | |
11299 | Namespace handles its own subscriptions. If set to @code{#f}, the | |
11300 | parent namespace handles them. The empty prefix should always have this | |
1068f26b | 11301 | as @code{#t}). |
d8c18af8 AW |
11302 | Defaults to @samp{#t}. |
11303 | @end deftypevr | |
11304 | ||
11305 | @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes | |
11306 | List of predefined mailboxes in this namespace. | |
11307 | Defaults to @samp{()}. | |
11308 | ||
11309 | Available @code{mailbox-configuration} fields are: | |
11310 | ||
11311 | @deftypevr {@code{mailbox-configuration} parameter} string name | |
11312 | Name for this mailbox. | |
11313 | @end deftypevr | |
11314 | ||
11315 | @deftypevr {@code{mailbox-configuration} parameter} string auto | |
11316 | @samp{create} will automatically create this mailbox. | |
11317 | @samp{subscribe} will both create and subscribe to the mailbox. | |
11318 | Defaults to @samp{"no"}. | |
11319 | @end deftypevr | |
11320 | ||
11321 | @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use | |
11322 | List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154. | |
11323 | Valid values are @code{\All}, @code{\Archive}, @code{\Drafts}, | |
11324 | @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}. | |
11325 | Defaults to @samp{()}. | |
11326 | @end deftypevr | |
11327 | ||
11328 | @end deftypevr | |
11329 | ||
11330 | @end deftypevr | |
11331 | ||
11332 | @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir | |
11333 | Base directory where to store runtime data. | |
11334 | Defaults to @samp{"/var/run/dovecot/"}. | |
11335 | @end deftypevr | |
11336 | ||
11337 | @deftypevr {@code{dovecot-configuration} parameter} string login-greeting | |
11338 | Greeting message for clients. | |
11339 | Defaults to @samp{"Dovecot ready."}. | |
11340 | @end deftypevr | |
11341 | ||
11342 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks | |
11343 | List of trusted network ranges. Connections from these IPs are | |
11344 | allowed to override their IP addresses and ports (for logging and for | |
11345 | authentication checks). @samp{disable-plaintext-auth} is also ignored | |
1068f26b | 11346 | for these networks. Typically you would specify your IMAP proxy servers |
d8c18af8 AW |
11347 | here. |
11348 | Defaults to @samp{()}. | |
11349 | @end deftypevr | |
11350 | ||
11351 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets | |
11352 | List of login access check sockets (e.g. tcpwrap). | |
11353 | Defaults to @samp{()}. | |
11354 | @end deftypevr | |
11355 | ||
11356 | @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle? | |
11357 | Show more verbose process titles (in ps). Currently shows user name | |
1068f26b AE |
11358 | and IP address. Useful for seeing who is actually using the IMAP |
11359 | processes (e.g. shared mailboxes or if the same uid is used for multiple | |
d8c18af8 AW |
11360 | accounts). |
11361 | Defaults to @samp{#f}. | |
11362 | @end deftypevr | |
11363 | ||
11364 | @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients? | |
11365 | Should all processes be killed when Dovecot master process shuts down. | |
11366 | Setting this to @code{#f} means that Dovecot can be upgraded without | |
11367 | forcing existing client connections to close (although that could also | |
1068f26b | 11368 | be a problem if the upgrade is e.g. due to a security fix). |
d8c18af8 AW |
11369 | Defaults to @samp{#t}. |
11370 | @end deftypevr | |
11371 | ||
11372 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count | |
11373 | If non-zero, run mail commands via this many connections to doveadm | |
11374 | server, instead of running them directly in the same process. | |
11375 | Defaults to @samp{0}. | |
11376 | @end deftypevr | |
11377 | ||
11378 | @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path | |
11379 | UNIX socket or host:port used for connecting to doveadm server. | |
11380 | Defaults to @samp{"doveadm-server"}. | |
11381 | @end deftypevr | |
11382 | ||
11383 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment | |
11384 | List of environment variables that are preserved on Dovecot startup | |
11385 | and passed down to all of its child processes. You can also give | |
11386 | key=value pairs to always set specific settings. | |
11387 | @end deftypevr | |
11388 | ||
11389 | @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth? | |
11390 | Disable LOGIN command and all other plaintext authentications unless | |
11391 | SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP | |
11392 | matches the local IP (i.e. you're connecting from the same computer), | |
11393 | the connection is considered secure and plaintext authentication is | |
11394 | allowed. See also ssl=required setting. | |
11395 | Defaults to @samp{#t}. | |
11396 | @end deftypevr | |
11397 | ||
11398 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size | |
11399 | Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled. | |
11400 | Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set | |
11401 | for caching to be used. | |
11402 | Defaults to @samp{0}. | |
11403 | @end deftypevr | |
11404 | ||
11405 | @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl | |
11406 | Time to live for cached data. After TTL expires the cached record | |
11407 | is no longer used, *except* if the main database lookup returns internal | |
11408 | failure. We also try to handle password changes automatically: If | |
11409 | user's previous authentication was successful, but this one wasn't, the | |
11410 | cache isn't used. For now this works only with plaintext | |
11411 | authentication. | |
11412 | Defaults to @samp{"1 hour"}. | |
11413 | @end deftypevr | |
11414 | ||
11415 | @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl | |
11416 | TTL for negative hits (user not found, password mismatch). | |
11417 | 0 disables caching them completely. | |
11418 | Defaults to @samp{"1 hour"}. | |
11419 | @end deftypevr | |
11420 | ||
11421 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms | |
11422 | List of realms for SASL authentication mechanisms that need them. | |
11423 | You can leave it empty if you don't want to support multiple realms. | |
11424 | Many clients simply use the first one listed here, so keep the default | |
11425 | realm first. | |
11426 | Defaults to @samp{()}. | |
11427 | @end deftypevr | |
11428 | ||
11429 | @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm | |
11430 | Default realm/domain to use if none was specified. This is used for | |
11431 | both SASL realms and appending @@domain to username in plaintext | |
11432 | logins. | |
11433 | Defaults to @samp{""}. | |
11434 | @end deftypevr | |
11435 | ||
11436 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars | |
11437 | List of allowed characters in username. If the user-given username | |
11438 | contains a character not listed in here, the login automatically fails. | |
11439 | This is just an extra check to make sure user can't exploit any | |
11440 | potential quote escaping vulnerabilities with SQL/LDAP databases. If | |
11441 | you want to allow all characters, set this value to empty. | |
11442 | Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}. | |
11443 | @end deftypevr | |
11444 | ||
11445 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation | |
11446 | Username character translations before it's looked up from | |
11447 | databases. The value contains series of from -> to characters. For | |
11448 | example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are | |
11449 | translated to @samp{@@}. | |
11450 | Defaults to @samp{""}. | |
11451 | @end deftypevr | |
11452 | ||
11453 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format | |
11454 | Username formatting before it's looked up from databases. You can | |
11455 | use the standard variables here, e.g. %Lu would lowercase the username, | |
11456 | %n would drop away the domain if it was given, or @samp{%n-AT-%d} would | |
11457 | change the @samp{@@} into @samp{-AT-}. This translation is done after | |
11458 | @samp{auth-username-translation} changes. | |
11459 | Defaults to @samp{"%Lu"}. | |
11460 | @end deftypevr | |
11461 | ||
11462 | @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator | |
11463 | If you want to allow master users to log in by specifying the master | |
11464 | username within the normal username string (i.e. not using SASL | |
11465 | mechanism's support for it), you can specify the separator character | |
11466 | here. The format is then <username><separator><master username>. | |
11467 | UW-IMAP uses @samp{*} as the separator, so that could be a good | |
11468 | choice. | |
11469 | Defaults to @samp{""}. | |
11470 | @end deftypevr | |
11471 | ||
11472 | @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username | |
11473 | Username to use for users logging in with ANONYMOUS SASL | |
11474 | mechanism. | |
11475 | Defaults to @samp{"anonymous"}. | |
11476 | @end deftypevr | |
11477 | ||
11478 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count | |
11479 | Maximum number of dovecot-auth worker processes. They're used to | |
11480 | execute blocking passdb and userdb queries (e.g. MySQL and PAM). | |
11481 | They're automatically created and destroyed as needed. | |
11482 | Defaults to @samp{30}. | |
11483 | @end deftypevr | |
11484 | ||
11485 | @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname | |
11486 | Host name to use in GSSAPI principal names. The default is to use | |
11487 | the name returned by gethostname(). Use @samp{$ALL} (with quotes) to | |
11488 | allow all keytab entries. | |
11489 | Defaults to @samp{""}. | |
11490 | @end deftypevr | |
11491 | ||
11492 | @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab | |
11493 | Kerberos keytab to use for the GSSAPI mechanism. Will use the | |
8b499030 | 11494 | system default (usually @file{/etc/krb5.keytab}) if not specified. You may |
d8c18af8 AW |
11495 | need to change the auth service to run as root to be able to read this |
11496 | file. | |
11497 | Defaults to @samp{""}. | |
11498 | @end deftypevr | |
11499 | ||
11500 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind? | |
11501 | Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon | |
11502 | and @samp{ntlm-auth} helper. | |
11503 | <doc/wiki/Authentication/Mechanisms/Winbind.txt>. | |
11504 | Defaults to @samp{#f}. | |
11505 | @end deftypevr | |
11506 | ||
11507 | @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path | |
11508 | Path for Samba's @samp{ntlm-auth} helper binary. | |
11509 | Defaults to @samp{"/usr/bin/ntlm_auth"}. | |
11510 | @end deftypevr | |
11511 | ||
11512 | @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay | |
11513 | Time to delay before replying to failed authentications. | |
11514 | Defaults to @samp{"2 secs"}. | |
11515 | @end deftypevr | |
11516 | ||
11517 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert? | |
11518 | Require a valid SSL client certificate or the authentication | |
11519 | fails. | |
11520 | Defaults to @samp{#f}. | |
11521 | @end deftypevr | |
11522 | ||
11523 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert? | |
11524 | Take the username from client's SSL certificate, using | |
11525 | @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's | |
11526 | CommonName. | |
11527 | Defaults to @samp{#f}. | |
11528 | @end deftypevr | |
11529 | ||
11530 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms | |
11531 | List of wanted authentication mechanisms. Supported mechanisms are: | |
11532 | @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5}, | |
11533 | @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi}, | |
11534 | @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also | |
11535 | @samp{disable-plaintext-auth} setting. | |
11536 | @end deftypevr | |
11537 | ||
11538 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers | |
11539 | List of IPs or hostnames to all director servers, including ourself. | |
11540 | Ports can be specified as ip:port. The default port is the same as what | |
11541 | director service's @samp{inet-listener} is using. | |
11542 | Defaults to @samp{()}. | |
11543 | @end deftypevr | |
11544 | ||
11545 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers | |
11546 | List of IPs or hostnames to all backend mail servers. Ranges are | |
11547 | allowed too, like 10.0.0.10-10.0.0.30. | |
11548 | Defaults to @samp{()}. | |
11549 | @end deftypevr | |
11550 | ||
11551 | @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire | |
11552 | How long to redirect users to a specific server after it no longer | |
11553 | has any connections. | |
11554 | Defaults to @samp{"15 min"}. | |
11555 | @end deftypevr | |
11556 | ||
11557 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer director-doveadm-port | |
11558 | TCP/IP port that accepts doveadm connections (instead of director | |
11559 | connections) If you enable this, you'll also need to add | |
11560 | @samp{inet-listener} for the port. | |
11561 | Defaults to @samp{0}. | |
11562 | @end deftypevr | |
11563 | ||
11564 | @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash | |
11565 | How the username is translated before being hashed. Useful values | |
11566 | include %Ln if user can log in with or without @@domain, %Ld if mailboxes | |
11567 | are shared within domain. | |
11568 | Defaults to @samp{"%Lu"}. | |
11569 | @end deftypevr | |
11570 | ||
11571 | @deftypevr {@code{dovecot-configuration} parameter} string log-path | |
11572 | Log file to use for error messages. @samp{syslog} logs to syslog, | |
11573 | @samp{/dev/stderr} logs to stderr. | |
11574 | Defaults to @samp{"syslog"}. | |
11575 | @end deftypevr | |
11576 | ||
11577 | @deftypevr {@code{dovecot-configuration} parameter} string info-log-path | |
11578 | Log file to use for informational messages. Defaults to | |
11579 | @samp{log-path}. | |
11580 | Defaults to @samp{""}. | |
11581 | @end deftypevr | |
11582 | ||
11583 | @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path | |
11584 | Log file to use for debug messages. Defaults to | |
11585 | @samp{info-log-path}. | |
11586 | Defaults to @samp{""}. | |
11587 | @end deftypevr | |
11588 | ||
11589 | @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility | |
11590 | Syslog facility to use if you're logging to syslog. Usually if you | |
11591 | don't want to use @samp{mail}, you'll use local0..local7. Also other | |
11592 | standard facilities are supported. | |
11593 | Defaults to @samp{"mail"}. | |
11594 | @end deftypevr | |
11595 | ||
11596 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose? | |
11597 | Log unsuccessful authentication attempts and the reasons why they | |
11598 | failed. | |
11599 | Defaults to @samp{#f}. | |
11600 | @end deftypevr | |
11601 | ||
11602 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords? | |
11603 | In case of password mismatches, log the attempted password. Valid | |
11604 | values are no, plain and sha1. sha1 can be useful for detecting brute | |
11605 | force password attempts vs. user simply trying the same password over | |
11606 | and over again. You can also truncate the value to n chars by appending | |
11607 | ":n" (e.g. sha1:6). | |
11608 | Defaults to @samp{#f}. | |
11609 | @end deftypevr | |
11610 | ||
11611 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug? | |
11612 | Even more verbose logging for debugging purposes. Shows for example | |
11613 | SQL queries. | |
11614 | Defaults to @samp{#f}. | |
11615 | @end deftypevr | |
11616 | ||
11617 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords? | |
11618 | In case of password mismatches, log the passwords and used scheme so | |
11619 | the problem can be debugged. Enabling this also enables | |
11620 | @samp{auth-debug}. | |
11621 | Defaults to @samp{#f}. | |
11622 | @end deftypevr | |
11623 | ||
11624 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug? | |
11625 | Enable mail process debugging. This can help you figure out why | |
11626 | Dovecot isn't finding your mails. | |
11627 | Defaults to @samp{#f}. | |
11628 | @end deftypevr | |
11629 | ||
11630 | @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl? | |
11631 | Show protocol level SSL errors. | |
11632 | Defaults to @samp{#f}. | |
11633 | @end deftypevr | |
11634 | ||
11635 | @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp | |
11636 | Prefix for each line written to log file. % codes are in | |
11637 | strftime(3) format. | |
11638 | Defaults to @samp{"\"%b %d %H:%M:%S \""}. | |
11639 | @end deftypevr | |
11640 | ||
11641 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements | |
11642 | List of elements we want to log. The elements which have a | |
11643 | non-empty variable value are joined together to form a comma-separated | |
11644 | string. | |
11645 | @end deftypevr | |
11646 | ||
11647 | @deftypevr {@code{dovecot-configuration} parameter} string login-log-format | |
11648 | Login log format. %s contains @samp{login-log-format-elements} | |
11649 | string, %$ contains the data we want to log. | |
11650 | Defaults to @samp{"%$: %s"}. | |
11651 | @end deftypevr | |
11652 | ||
11653 | @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix | |
11654 | Log prefix for mail processes. See doc/wiki/Variables.txt for list | |
11655 | of possible variables you can use. | |
11656 | Defaults to @samp{"\"%s(%u): \""}. | |
11657 | @end deftypevr | |
11658 | ||
11659 | @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format | |
11660 | Format to use for logging mail deliveries. You can use variables: | |
11661 | @table @code | |
11662 | @item %$ | |
11663 | Delivery status message (e.g. @samp{saved to INBOX}) | |
11664 | @item %m | |
11665 | Message-ID | |
11666 | @item %s | |
11667 | Subject | |
11668 | @item %f | |
11669 | From address | |
11670 | @item %p | |
11671 | Physical size | |
11672 | @item %w | |
11673 | Virtual size. | |
11674 | @end table | |
11675 | Defaults to @samp{"msgid=%m: %$"}. | |
11676 | @end deftypevr | |
11677 | ||
11678 | @deftypevr {@code{dovecot-configuration} parameter} string mail-location | |
11679 | Location for users' mailboxes. The default is empty, which means | |
11680 | that Dovecot tries to find the mailboxes automatically. This won't work | |
11681 | if the user doesn't yet have any mail, so you should explicitly tell | |
11682 | Dovecot the full location. | |
11683 | ||
11684 | If you're using mbox, giving a path to the INBOX | |
11685 | file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot | |
11686 | where the other mailboxes are kept. This is called the "root mail | |
11687 | directory", and it must be the first path given in the | |
11688 | @samp{mail-location} setting. | |
11689 | ||
11690 | There are a few special variables you can use, eg.: | |
11691 | ||
11692 | @table @samp | |
11693 | @item %u | |
11694 | username | |
11695 | @item %n | |
11696 | user part in user@@domain, same as %u if there's no domain | |
11697 | @item %d | |
11698 | domain part in user@@domain, empty if there's no domain | |
11699 | @item %h | |
11700 | home director | |
11701 | @end table | |
11702 | ||
11703 | See doc/wiki/Variables.txt for full list. Some examples: | |
11704 | @table @samp | |
11705 | @item maildir:~/Maildir | |
11706 | @item mbox:~/mail:INBOX=/var/mail/%u | |
11707 | @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/% | |
11708 | @end table | |
11709 | Defaults to @samp{""}. | |
11710 | @end deftypevr | |
11711 | ||
11712 | @deftypevr {@code{dovecot-configuration} parameter} string mail-uid | |
11713 | System user and group used to access mails. If you use multiple, | |
11714 | userdb can override these by returning uid or gid fields. You can use | |
11715 | either numbers or names. <doc/wiki/UserIds.txt>. | |
11716 | Defaults to @samp{""}. | |
11717 | @end deftypevr | |
11718 | ||
11719 | @deftypevr {@code{dovecot-configuration} parameter} string mail-gid | |
11720 | ||
11721 | Defaults to @samp{""}. | |
11722 | @end deftypevr | |
11723 | ||
11724 | @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group | |
11725 | Group to enable temporarily for privileged operations. Currently | |
11726 | this is used only with INBOX when either its initial creation or | |
11727 | dotlocking fails. Typically this is set to "mail" to give access to | |
11728 | /var/mail. | |
11729 | Defaults to @samp{""}. | |
11730 | @end deftypevr | |
11731 | ||
11732 | @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups | |
11733 | Grant access to these supplementary groups for mail processes. | |
11734 | Typically these are used to set up access to shared mailboxes. Note | |
11735 | that it may be dangerous to set these if users can create | |
11736 | symlinks (e.g. if "mail" group is set here, ln -s /var/mail ~/mail/var | |
11737 | could allow a user to delete others' mailboxes, or ln -s | |
11738 | /secret/shared/box ~/mail/mybox would allow reading it). | |
11739 | Defaults to @samp{""}. | |
11740 | @end deftypevr | |
11741 | ||
11742 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access? | |
8f65585b | 11743 | Allow full file system access to clients. There's no access checks |
d8c18af8 AW |
11744 | other than what the operating system does for the active UID/GID. It |
11745 | works with both maildir and mboxes, allowing you to prefix mailboxes | |
11746 | names with e.g. /path/ or ~user/. | |
11747 | Defaults to @samp{#f}. | |
11748 | @end deftypevr | |
11749 | ||
11750 | @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable? | |
11751 | Don't use mmap() at all. This is required if you store indexes to | |
8f65585b | 11752 | shared file systems (NFS or clustered file system). |
d8c18af8 AW |
11753 | Defaults to @samp{#f}. |
11754 | @end deftypevr | |
11755 | ||
11756 | @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl? | |
11757 | Rely on @samp{O_EXCL} to work when creating dotlock files. NFS | |
11758 | supports @samp{O_EXCL} since version 3, so this should be safe to use | |
11759 | nowadays by default. | |
11760 | Defaults to @samp{#t}. | |
11761 | @end deftypevr | |
11762 | ||
11763 | @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync | |
11764 | When to use fsync() or fdatasync() calls: | |
11765 | @table @code | |
11766 | @item optimized | |
11767 | Whenever necessary to avoid losing important data | |
11768 | @item always | |
11769 | Useful with e.g. NFS when write()s are delayed | |
11770 | @item never | |
11771 | Never use it (best performance, but crashes can lose data). | |
11772 | @end table | |
11773 | Defaults to @samp{"optimized"}. | |
11774 | @end deftypevr | |
11775 | ||
11776 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage? | |
11777 | Mail storage exists in NFS. Set this to yes to make Dovecot flush | |
11778 | NFS caches whenever needed. If you're using only a single mail server | |
11779 | this isn't needed. | |
11780 | Defaults to @samp{#f}. | |
11781 | @end deftypevr | |
11782 | ||
11783 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index? | |
11784 | Mail index files also exist in NFS. Setting this to yes requires | |
11785 | @samp{mmap-disable? #t} and @samp{fsync-disable? #f}. | |
11786 | Defaults to @samp{#f}. | |
11787 | @end deftypevr | |
11788 | ||
11789 | @deftypevr {@code{dovecot-configuration} parameter} string lock-method | |
11790 | Locking method for index files. Alternatives are fcntl, flock and | |
11791 | dotlock. Dotlocking uses some tricks which may create more disk I/O | |
11792 | than other locking methods. NFS users: flock doesn't work, remember to | |
11793 | change @samp{mmap-disable}. | |
11794 | Defaults to @samp{"fcntl"}. | |
11795 | @end deftypevr | |
11796 | ||
11797 | @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir | |
11798 | Directory in which LDA/LMTP temporarily stores incoming mails >128 | |
11799 | kB. | |
11800 | Defaults to @samp{"/tmp"}. | |
11801 | @end deftypevr | |
11802 | ||
11803 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid | |
11804 | Valid UID range for users. This is mostly to make sure that users can't | |
11805 | log in as daemons or other system users. Note that denying root logins is | |
11806 | hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid} | |
11807 | is set to 0. | |
11808 | Defaults to @samp{500}. | |
11809 | @end deftypevr | |
11810 | ||
11811 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid | |
11812 | ||
11813 | Defaults to @samp{0}. | |
11814 | @end deftypevr | |
11815 | ||
11816 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid | |
11817 | Valid GID range for users. Users having non-valid GID as primary group ID | |
11818 | aren't allowed to log in. If user belongs to supplementary groups with | |
11819 | non-valid GIDs, those groups are not set. | |
11820 | Defaults to @samp{1}. | |
11821 | @end deftypevr | |
11822 | ||
11823 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid | |
11824 | ||
11825 | Defaults to @samp{0}. | |
11826 | @end deftypevr | |
11827 | ||
11828 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length | |
11829 | Maximum allowed length for mail keyword name. It's only forced when | |
11830 | trying to create new keywords. | |
11831 | Defaults to @samp{50}. | |
11832 | @end deftypevr | |
11833 | ||
11834 | @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs | |
11835 | List of directories under which chrooting is allowed for mail | |
11836 | processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar | |
11837 | too). This setting doesn't affect @samp{login-chroot} | |
11838 | @samp{mail-chroot} or auth chroot settings. If this setting is empty, | |
11839 | "/./" in home dirs are ignored. WARNING: Never add directories here | |
11840 | which local users can modify, that may lead to root exploit. Usually | |
11841 | this should be done only if you don't allow shell access for users. | |
11842 | <doc/wiki/Chrooting.txt>. | |
11843 | Defaults to @samp{()}. | |
11844 | @end deftypevr | |
11845 | ||
11846 | @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot | |
11847 | Default chroot directory for mail processes. This can be overridden | |
11848 | for specific users in user database by giving /./ in user's home | |
11849 | directory (e.g. /home/./user chroots into /home). Note that usually | |
11850 | there is no real need to do chrooting, Dovecot doesn't allow users to | |
11851 | access files outside their mail directory anyway. If your home | |
11852 | directories are prefixed with the chroot directory, append "/." to | |
11853 | @samp{mail-chroot}. <doc/wiki/Chrooting.txt>. | |
11854 | Defaults to @samp{""}. | |
11855 | @end deftypevr | |
11856 | ||
11857 | @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path | |
11858 | UNIX socket path to master authentication server to find users. | |
11859 | This is used by imap (for shared users) and lda. | |
11860 | Defaults to @samp{"/var/run/dovecot/auth-userdb"}. | |
11861 | @end deftypevr | |
11862 | ||
11863 | @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir | |
11864 | Directory where to look up mail plugins. | |
11865 | Defaults to @samp{"/usr/lib/dovecot"}. | |
11866 | @end deftypevr | |
11867 | ||
11868 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins | |
11869 | List of plugins to load for all services. Plugins specific to IMAP, | |
11870 | LDA, etc. are added to this list in their own .conf files. | |
11871 | Defaults to @samp{()}. | |
11872 | @end deftypevr | |
11873 | ||
11874 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count | |
11875 | The minimum number of mails in a mailbox before updates are done to | |
11876 | cache file. This allows optimizing Dovecot's behavior to do less disk | |
11877 | writes at the cost of more disk reads. | |
11878 | Defaults to @samp{0}. | |
11879 | @end deftypevr | |
11880 | ||
11881 | @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval | |
11882 | When IDLE command is running, mailbox is checked once in a while to | |
11883 | see if there are any new mails or other changes. This setting defines | |
11884 | the minimum time to wait between those checks. Dovecot can also use | |
11885 | dnotify, inotify and kqueue to find out immediately when changes | |
11886 | occur. | |
11887 | Defaults to @samp{"30 secs"}. | |
11888 | @end deftypevr | |
11889 | ||
11890 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf? | |
11891 | Save mails with CR+LF instead of plain LF. This makes sending those | |
11892 | mails take less CPU, especially with sendfile() syscall with Linux and | |
11893 | FreeBSD. But it also creates a bit more disk I/O which may just make it | |
11894 | slower. Also note that if other software reads the mboxes/maildirs, | |
11895 | they may handle the extra CRs wrong and cause problems. | |
11896 | Defaults to @samp{#f}. | |
11897 | @end deftypevr | |
11898 | ||
11899 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs? | |
11900 | By default LIST command returns all entries in maildir beginning | |
11901 | with a dot. Enabling this option makes Dovecot return only entries | |
11902 | which are directories. This is done by stat()ing each entry, so it | |
11903 | causes more disk I/O. | |
11904 | (For systems setting struct @samp{dirent->d_type} this check is free | |
11905 | and it's done always regardless of this setting). | |
11906 | Defaults to @samp{#f}. | |
11907 | @end deftypevr | |
11908 | ||
11909 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks? | |
11910 | When copying a message, do it with hard links whenever possible. | |
11911 | This makes the performance much better, and it's unlikely to have any | |
11912 | side effects. | |
11913 | Defaults to @samp{#t}. | |
11914 | @end deftypevr | |
11915 | ||
11916 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs? | |
11917 | Assume Dovecot is the only MUA accessing Maildir: Scan cur/ | |
11918 | directory only when its mtime changes unexpectedly or when we can't find | |
11919 | the mail otherwise. | |
11920 | Defaults to @samp{#f}. | |
11921 | @end deftypevr | |
11922 | ||
11923 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks | |
11924 | Which locking methods to use for locking mbox. There are four | |
11925 | available: | |
11926 | ||
11927 | @table @code | |
11928 | @item dotlock | |
11929 | Create <mailbox>.lock file. This is the oldest and most NFS-safe | |
11930 | solution. If you want to use /var/mail/ like directory, the users will | |
11931 | need write access to that directory. | |
11932 | @item dotlock-try | |
11933 | Same as dotlock, but if it fails because of permissions or because there | |
11934 | isn't enough disk space, just skip it. | |
11935 | @item fcntl | |
11936 | Use this if possible. Works with NFS too if lockd is used. | |
11937 | @item flock | |
a01ad638 | 11938 | May not exist in all systems. Doesn't work with NFS. |
d8c18af8 AW |
11939 | @item lockf |
11940 | May not exist in all systems. Doesn't work with NFS. | |
11941 | @end table | |
11942 | ||
11943 | You can use multiple locking methods; if you do the order they're declared | |
11944 | in is important to avoid deadlocks if other MTAs/MUAs are using multiple | |
11945 | locking methods as well. Some operating systems don't allow using some of | |
11946 | them simultaneously. | |
11947 | @end deftypevr | |
11948 | ||
11949 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks | |
11950 | ||
11951 | @end deftypevr | |
11952 | ||
11953 | @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout | |
11954 | Maximum time to wait for lock (all of them) before aborting. | |
11955 | Defaults to @samp{"5 mins"}. | |
11956 | @end deftypevr | |
11957 | ||
11958 | @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout | |
11959 | If dotlock exists but the mailbox isn't modified in any way, | |
11960 | override the lock file after this much time. | |
11961 | Defaults to @samp{"2 mins"}. | |
11962 | @end deftypevr | |
11963 | ||
11964 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs? | |
11965 | When mbox changes unexpectedly we have to fully read it to find out | |
11966 | what changed. If the mbox is large this can take a long time. Since | |
11967 | the change is usually just a newly appended mail, it'd be faster to | |
11968 | simply read the new mails. If this setting is enabled, Dovecot does | |
11969 | this but still safely fallbacks to re-reading the whole mbox file | |
11970 | whenever something in mbox isn't how it's expected to be. The only real | |
11971 | downside to this setting is that if some other MUA changes message | |
11972 | flags, Dovecot doesn't notice it immediately. Note that a full sync is | |
11973 | done with SELECT, EXAMINE, EXPUNGE and CHECK commands. | |
11974 | Defaults to @samp{#t}. | |
11975 | @end deftypevr | |
11976 | ||
11977 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs? | |
11978 | Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT, | |
11979 | EXAMINE, EXPUNGE or CHECK commands. If this is set, | |
11980 | @samp{mbox-dirty-syncs} is ignored. | |
11981 | Defaults to @samp{#f}. | |
11982 | @end deftypevr | |
11983 | ||
11984 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes? | |
11985 | Delay writing mbox headers until doing a full write sync (EXPUNGE | |
11986 | and CHECK commands and when closing the mailbox). This is especially | |
11987 | useful for POP3 where clients often delete all mails. The downside is | |
11988 | that our changes aren't immediately visible to other MUAs. | |
11989 | Defaults to @samp{#t}. | |
11990 | @end deftypevr | |
11991 | ||
11992 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size | |
11993 | If mbox size is smaller than this (e.g. 100k), don't write index | |
11994 | files. If an index file already exists it's still read, just not | |
11995 | updated. | |
11996 | Defaults to @samp{0}. | |
11997 | @end deftypevr | |
11998 | ||
11999 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size | |
12000 | Maximum dbox file size until it's rotated. | |
12001 | Defaults to @samp{2000000}. | |
12002 | @end deftypevr | |
12003 | ||
12004 | @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval | |
12005 | Maximum dbox file age until it's rotated. Typically in days. Day | |
12006 | begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check | |
12007 | disabled. | |
12008 | Defaults to @samp{"1d"}. | |
12009 | @end deftypevr | |
12010 | ||
12011 | @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space? | |
12012 | When creating new mdbox files, immediately preallocate their size to | |
12013 | @samp{mdbox-rotate-size}. This setting currently works only in Linux | |
8f65585b | 12014 | with some file systems (ext4, xfs). |
d8c18af8 AW |
12015 | Defaults to @samp{#f}. |
12016 | @end deftypevr | |
12017 | ||
12018 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir | |
12019 | sdbox and mdbox support saving mail attachments to external files, | |
12020 | which also allows single instance storage for them. Other backends | |
12021 | don't support this for now. | |
12022 | ||
12023 | WARNING: This feature hasn't been tested much yet. Use at your own risk. | |
12024 | ||
12025 | Directory root where to store mail attachments. Disabled, if empty. | |
12026 | Defaults to @samp{""}. | |
12027 | @end deftypevr | |
12028 | ||
12029 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size | |
12030 | Attachments smaller than this aren't saved externally. It's also | |
12031 | possible to write a plugin to disable saving specific attachments | |
12032 | externally. | |
12033 | Defaults to @samp{128000}. | |
12034 | @end deftypevr | |
12035 | ||
12036 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs | |
8f65585b | 12037 | File system backend to use for saving attachments: |
d8c18af8 AW |
12038 | @table @code |
12039 | @item posix | |
12040 | No SiS done by Dovecot (but this might help FS's own deduplication) | |
12041 | @item sis posix | |
12042 | SiS with immediate byte-by-byte comparison during saving | |
12043 | @item sis-queue posix | |
12044 | SiS with delayed comparison and deduplication. | |
12045 | @end table | |
12046 | Defaults to @samp{"sis posix"}. | |
12047 | @end deftypevr | |
12048 | ||
12049 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash | |
12050 | Hash format to use in attachment filenames. You can add any text and | |
12051 | variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}}, | |
12052 | @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be | |
12053 | truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits. | |
12054 | Defaults to @samp{"%@{sha1@}"}. | |
12055 | @end deftypevr | |
12056 | ||
12057 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit | |
12058 | ||
12059 | Defaults to @samp{100}. | |
12060 | @end deftypevr | |
12061 | ||
12062 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit | |
12063 | ||
12064 | Defaults to @samp{1000}. | |
12065 | @end deftypevr | |
12066 | ||
12067 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit | |
12068 | Default VSZ (virtual memory size) limit for service processes. | |
12069 | This is mainly intended to catch and kill processes that leak memory | |
12070 | before they eat up everything. | |
12071 | Defaults to @samp{256000000}. | |
12072 | @end deftypevr | |
12073 | ||
12074 | @deftypevr {@code{dovecot-configuration} parameter} string default-login-user | |
12075 | Login user is internally used by login processes. This is the most | |
12076 | untrusted user in Dovecot system. It shouldn't have access to anything | |
12077 | at all. | |
12078 | Defaults to @samp{"dovenull"}. | |
12079 | @end deftypevr | |
12080 | ||
12081 | @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user | |
12082 | Internal user is used by unprivileged processes. It should be | |
12083 | separate from login user, so that login processes can't disturb other | |
12084 | processes. | |
12085 | Defaults to @samp{"dovecot"}. | |
12086 | @end deftypevr | |
12087 | ||
12088 | @deftypevr {@code{dovecot-configuration} parameter} string ssl? | |
12089 | SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>. | |
12090 | Defaults to @samp{"required"}. | |
12091 | @end deftypevr | |
12092 | ||
12093 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert | |
12094 | PEM encoded X.509 SSL/TLS certificate (public key). | |
12095 | Defaults to @samp{"</etc/dovecot/default.pem"}. | |
12096 | @end deftypevr | |
12097 | ||
12098 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-key | |
12099 | PEM encoded SSL/TLS private key. The key is opened before | |
12100 | dropping root privileges, so keep the key file unreadable by anyone but | |
12101 | root. | |
12102 | Defaults to @samp{"</etc/dovecot/private/default.pem"}. | |
12103 | @end deftypevr | |
12104 | ||
12105 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password | |
12106 | If key file is password protected, give the password here. | |
12107 | Alternatively give it when starting dovecot with -p parameter. Since | |
12108 | this file is often world-readable, you may want to place this setting | |
12109 | instead to a different. | |
12110 | Defaults to @samp{""}. | |
12111 | @end deftypevr | |
12112 | ||
12113 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca | |
12114 | PEM encoded trusted certificate authority. Set this only if you | |
12115 | intend to use @samp{ssl-verify-client-cert? #t}. The file should | |
12116 | contain the CA certificate(s) followed by the matching | |
12117 | CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}). | |
12118 | Defaults to @samp{""}. | |
12119 | @end deftypevr | |
12120 | ||
12121 | @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl? | |
12122 | Require that CRL check succeeds for client certificates. | |
12123 | Defaults to @samp{#t}. | |
12124 | @end deftypevr | |
12125 | ||
12126 | @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert? | |
12127 | Request client to send a certificate. If you also want to require | |
12128 | it, set @samp{auth-ssl-require-client-cert? #t} in auth section. | |
12129 | Defaults to @samp{#f}. | |
12130 | @end deftypevr | |
12131 | ||
12132 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field | |
12133 | Which field from certificate to use for username. commonName and | |
12134 | x500UniqueIdentifier are the usual choices. You'll also need to set | |
12135 | @samp{auth-ssl-username-from-cert? #t}. | |
12136 | Defaults to @samp{"commonName"}. | |
12137 | @end deftypevr | |
12138 | ||
12139 | @deftypevr {@code{dovecot-configuration} parameter} hours ssl-parameters-regenerate | |
12140 | How often to regenerate the SSL parameters file. Generation is | |
12141 | quite CPU intensive operation. The value is in hours, 0 disables | |
12142 | regeneration entirely. | |
12143 | Defaults to @samp{168}. | |
12144 | @end deftypevr | |
12145 | ||
12146 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-protocols | |
12147 | SSL protocols to use. | |
12148 | Defaults to @samp{"!SSLv2"}. | |
12149 | @end deftypevr | |
12150 | ||
12151 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list | |
12152 | SSL ciphers to use. | |
12153 | Defaults to @samp{"ALL:!LOW:!SSLv2:!EXP:!aNULL"}. | |
12154 | @end deftypevr | |
12155 | ||
12156 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device | |
12157 | SSL crypto device to use, for valid values run "openssl engine". | |
12158 | Defaults to @samp{""}. | |
12159 | @end deftypevr | |
12160 | ||
12161 | @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address | |
12162 | Address to use when sending rejection mails. | |
66329c23 AW |
12163 | %d expands to recipient domain. |
12164 | Defaults to @samp{"postmaster@@%d"}. | |
d8c18af8 AW |
12165 | @end deftypevr |
12166 | ||
12167 | @deftypevr {@code{dovecot-configuration} parameter} string hostname | |
12168 | Hostname to use in various parts of sent mails (e.g. in Message-Id) | |
12169 | and in LMTP replies. Default is the system's real hostname@@domain. | |
12170 | Defaults to @samp{""}. | |
12171 | @end deftypevr | |
12172 | ||
12173 | @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail? | |
12174 | If user is over quota, return with temporary failure instead of | |
12175 | bouncing the mail. | |
12176 | Defaults to @samp{#f}. | |
12177 | @end deftypevr | |
12178 | ||
12179 | @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path | |
12180 | Binary to use for sending mails. | |
12181 | Defaults to @samp{"/usr/sbin/sendmail"}. | |
12182 | @end deftypevr | |
12183 | ||
12184 | @deftypevr {@code{dovecot-configuration} parameter} string submission-host | |
12185 | If non-empty, send mails via this SMTP host[:port] instead of | |
12186 | sendmail. | |
12187 | Defaults to @samp{""}. | |
12188 | @end deftypevr | |
12189 | ||
12190 | @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject | |
12191 | Subject: header to use for rejection mails. You can use the same | |
12192 | variables as for @samp{rejection-reason} below. | |
12193 | Defaults to @samp{"Rejected: %s"}. | |
12194 | @end deftypevr | |
12195 | ||
12196 | @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason | |
12197 | Human readable error message for rejection mails. You can use | |
12198 | variables: | |
12199 | ||
12200 | @table @code | |
12201 | @item %n | |
12202 | CRLF | |
12203 | @item %r | |
12204 | reason | |
12205 | @item %s | |
12206 | original subject | |
12207 | @item %t | |
12208 | recipient | |
12209 | @end table | |
12210 | Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}. | |
12211 | @end deftypevr | |
12212 | ||
12213 | @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter | |
12214 | Delimiter character between local-part and detail in email | |
12215 | address. | |
12216 | Defaults to @samp{"+"}. | |
12217 | @end deftypevr | |
12218 | ||
12219 | @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header | |
12220 | Header where the original recipient address (SMTP's RCPT TO: | |
12221 | address) is taken from if not available elsewhere. With dovecot-lda -a | |
12222 | parameter overrides this. A commonly used header for this is | |
12223 | X-Original-To. | |
12224 | Defaults to @samp{""}. | |
12225 | @end deftypevr | |
12226 | ||
12227 | @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate? | |
12228 | Should saving a mail to a nonexistent mailbox automatically create | |
12229 | it?. | |
12230 | Defaults to @samp{#f}. | |
12231 | @end deftypevr | |
12232 | ||
12233 | @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe? | |
12234 | Should automatically created mailboxes be also automatically | |
12235 | subscribed?. | |
12236 | Defaults to @samp{#f}. | |
12237 | @end deftypevr | |
12238 | ||
12239 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length | |
12240 | Maximum IMAP command line length. Some clients generate very long | |
12241 | command lines with huge mailboxes, so you may need to raise this if you | |
12242 | get "Too long argument" or "IMAP command line too large" errors | |
12243 | often. | |
12244 | Defaults to @samp{64000}. | |
12245 | @end deftypevr | |
12246 | ||
12247 | @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format | |
12248 | IMAP logout format string: | |
12249 | @table @code | |
12250 | @item %i | |
12251 | total number of bytes read from client | |
12252 | @item %o | |
12253 | total number of bytes sent to client. | |
12254 | @end table | |
12255 | Defaults to @samp{"in=%i out=%o"}. | |
12256 | @end deftypevr | |
12257 | ||
12258 | @deftypevr {@code{dovecot-configuration} parameter} string imap-capability | |
12259 | Override the IMAP CAPABILITY response. If the value begins with '+', | |
12260 | add the given capabilities on top of the defaults (e.g. +XFOO XBAR). | |
12261 | Defaults to @samp{""}. | |
12262 | @end deftypevr | |
12263 | ||
12264 | @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval | |
12265 | How long to wait between "OK Still here" notifications when client | |
12266 | is IDLEing. | |
12267 | Defaults to @samp{"2 mins"}. | |
12268 | @end deftypevr | |
12269 | ||
12270 | @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send | |
12271 | ID field names and values to send to clients. Using * as the value | |
12272 | makes Dovecot use the default value. The following fields have default | |
12273 | values currently: name, version, os, os-version, support-url, | |
12274 | support-email. | |
12275 | Defaults to @samp{""}. | |
12276 | @end deftypevr | |
12277 | ||
12278 | @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log | |
12279 | ID fields sent by client to log. * means everything. | |
12280 | Defaults to @samp{""}. | |
12281 | @end deftypevr | |
12282 | ||
12283 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds | |
12284 | Workarounds for various client bugs: | |
12285 | ||
12286 | @table @code | |
12287 | @item delay-newmail | |
12288 | Send EXISTS/RECENT new mail notifications only when replying to NOOP and | |
12289 | CHECK commands. Some clients ignore them otherwise, for example OSX | |
12290 | Mail (<v2.1). Outlook Express breaks more badly though, without this it | |
12291 | may show user "Message no longer in server" errors. Note that OE6 | |
12292 | still breaks even with this workaround if synchronization is set to | |
12293 | "Headers Only". | |
12294 | ||
12295 | @item tb-extra-mailbox-sep | |
12296 | Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and | |
12297 | adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to | |
12298 | ignore the extra @samp{/} instead of treating it as invalid mailbox name. | |
12299 | ||
12300 | @item tb-lsub-flags | |
12301 | Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox). | |
12302 | This makes Thunderbird realize they aren't selectable and show them | |
12303 | greyed out, instead of only later giving "not selectable" popup error. | |
12304 | @end table | |
12305 | Defaults to @samp{()}. | |
12306 | @end deftypevr | |
12307 | ||
12308 | @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host | |
12309 | Host allowed in URLAUTH URLs sent by client. "*" allows all. | |
12310 | Defaults to @samp{""}. | |
12311 | @end deftypevr | |
12312 | ||
12313 | ||
12314 | Whew! Lots of configuration options. The nice thing about it though is | |
12315 | that GuixSD has a complete interface to Dovecot's configuration | |
12316 | language. This allows not only a nice way to declare configurations, | |
12317 | but also offers reflective capabilities as well: users can write code to | |
12318 | inspect and transform configurations from within Scheme. | |
12319 | ||
12320 | However, it could be that you just want to get a @code{dovecot.conf} up | |
12321 | and running. In that case, you can pass an | |
7414de0a | 12322 | @code{opaque-dovecot-configuration} as the @code{#:config} parameter to |
d8c18af8 AW |
12323 | @code{dovecot-service}. As its name indicates, an opaque configuration |
12324 | does not have easy reflective capabilities. | |
12325 | ||
12326 | Available @code{opaque-dovecot-configuration} fields are: | |
12327 | ||
12328 | @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot | |
12329 | The dovecot package. | |
12330 | @end deftypevr | |
12331 | ||
12332 | @deftypevr {@code{opaque-dovecot-configuration} parameter} string string | |
12333 | The contents of the @code{dovecot.conf}, as a string. | |
12334 | @end deftypevr | |
12335 | ||
12336 | For example, if your @code{dovecot.conf} is just the empty string, you | |
12337 | could instantiate a dovecot service like this: | |
12338 | ||
12339 | @example | |
12340 | (dovecot-service #:config | |
12341 | (opaque-dovecot-configuration | |
12342 | (string ""))) | |
12343 | @end example | |
12344 | ||
f88371e8 SB |
12345 | @subsubheading OpenSMTPD Service |
12346 | ||
12347 | @deffn {Scheme Variable} opensmtpd-service-type | |
12348 | This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD} | |
12349 | service, whose value should be an @code{opensmtpd-configuration} object | |
12350 | as in this example: | |
12351 | ||
12352 | @example | |
12353 | (service opensmtpd-service-type | |
12354 | (opensmtpd-configuration | |
12355 | (config-file (local-file "./my-smtpd.conf")))) | |
12356 | @end example | |
12357 | @end deffn | |
12358 | ||
12359 | @deftp {Data Type} opensmtpd-configuration | |
12360 | Data type regresenting the configuration of opensmtpd. | |
12361 | ||
12362 | @table @asis | |
12363 | @item @code{package} (default: @var{opensmtpd}) | |
12364 | Package object of the OpenSMTPD SMTP server. | |
12365 | ||
12366 | @item @code{config-file} (default: @var{%default-opensmtpd-file}) | |
12367 | File-like object of the OpenSMTPD configuration file to use. By default | |
12368 | it listens on the loopback network interface, and allows for mail from | |
12369 | users and daemons on the local machine, as well as permitting email to | |
12370 | remote servers. Run @command{man smtpd.conf} for more information. | |
12371 | ||
12372 | @end table | |
12373 | @end deftp | |
859e367d | 12374 | |
82ccc499 CZ |
12375 | @subsubheading Exim Service |
12376 | ||
12377 | @deffn {Scheme Variable} exim-service-type | |
12378 | This is the type of the @uref{https://exim.org, Exim} service, whose value | |
12379 | should be an @code{exim-configuration} object as in this example: | |
12380 | ||
12381 | @example | |
12382 | (service exim-service-type | |
12383 | (exim-configuration | |
12384 | (config-file (local-file "./my-exim.conf")) | |
12385 | (aliases '(("postmaster" "bob") | |
12386 | ("bob" "bob@@example.com" "bob@@example2.com"))))) | |
12387 | @end example | |
12388 | @end deffn | |
12389 | ||
12390 | @deftp {Data Type} exim-configuration | |
12391 | Data type representing the configuration of exim. | |
12392 | ||
12393 | @table @asis | |
12394 | @item @code{package} (default: @var{exim}) | |
12395 | Package object of the Exim server. | |
12396 | ||
12397 | @item @code{config-file} (default: @code{#f}) | |
12398 | File-like object of the Exim configuration file to use. If its value is | |
12399 | @code{#f} then use the default configuration file from the package | |
12400 | provided in @code{package}. The resulting configuration file is loaded | |
12401 | after setting the @code{exim_user} and @code{exim_group} configuration | |
12402 | variables. | |
12403 | ||
12404 | @item @code{aliases} (default: @code{'()}) | |
12405 | List of aliases to use when delivering mail on this system. The | |
12406 | @code{car} of each list is used to match incoming mail, with the | |
12407 | @code{cdr} of each list designating how to deliver it. There may be many | |
12408 | delivery methods provided, in which case the mail is delivered to them | |
12409 | all. | |
12410 | ||
12411 | @end table | |
12412 | @end deftp | |
12413 | ||
78cef99b CL |
12414 | @node Messaging Services |
12415 | @subsubsection Messaging Services | |
12416 | ||
12417 | @cindex messaging | |
12418 | @cindex jabber | |
12419 | @cindex XMPP | |
12420 | The @code{(gnu services messaging)} module provides Guix service | |
12421 | definitions for messaging services: currently only Prosody is supported. | |
12422 | ||
12423 | @subsubheading Prosody Service | |
12424 | ||
12425 | @deffn {Scheme Variable} prosody-service-type | |
12426 | This is the type for the @uref{http://prosody.im, Prosody XMPP | |
12427 | communication server}. Its value must be a @code{prosody-configuration} | |
12428 | record as in this example: | |
12429 | ||
12430 | @example | |
12431 | (service prosody-service-type | |
12432 | (prosody-configuration | |
12433 | (modules-enabled (cons "groups" %default-modules-enabled)) | |
12434 | (int-components | |
12435 | (list | |
12436 | (int-component-configuration | |
12437 | (hostname "conference.example.net") | |
12438 | (plugin "muc") | |
12439 | (mod-muc (mod-muc-configuration))))) | |
12440 | (virtualhosts | |
12441 | (list | |
12442 | (virtualhost-configuration | |
12443 | (domain "example.net")))))) | |
12444 | @end example | |
12445 | ||
12446 | See below for details about @code{prosody-configuration}. | |
12447 | ||
12448 | @end deffn | |
12449 | ||
12450 | By default, Prosody does not need much configuration. Only one | |
12451 | @code{virtualhosts} field is needed: it specifies the domain you wish | |
12452 | Prosody to serve. | |
12453 | ||
12454 | Prosodyctl will help you generate X.509 certificates and keys: | |
12455 | ||
12456 | @example | |
12457 | prosodyctl cert request example.net | |
12458 | @end example | |
12459 | ||
12460 | The available configuration parameters follow. Each parameter | |
12461 | definition is preceded by its type; for example, @samp{string-list foo} | |
12462 | indicates that the @code{foo} parameter should be specified as a list of | |
12463 | strings. Types starting with @code{maybe-} denote parameters that won't | |
12464 | show up in @code{prosody.cfg.lua} when their value is @code{'disabled}. | |
12465 | ||
12466 | There is also a way to specify the configuration as a string, if you | |
12467 | have an old @code{prosody.cfg.lua} file that you want to port over from | |
12468 | some other system; see the end for more details. | |
12469 | ||
12470 | @c The following documentation was initially generated by | |
12471 | @c (generate-documentation) in (gnu services messaging). Manually maintained | |
12472 | @c documentation is better, so we shouldn't hesitate to edit below as | |
12473 | @c needed. However if the change you want to make to this documentation | |
12474 | @c can be done in an automated way, it's probably easier to change | |
12475 | @c (generate-documentation) than to make it below and have to deal with | |
12476 | @c the churn as Prosody updates. | |
12477 | ||
12478 | Available @code{prosody-configuration} fields are: | |
12479 | ||
12480 | @deftypevr {@code{prosody-configuration} parameter} package prosody | |
12481 | The Prosody package. | |
12482 | @end deftypevr | |
12483 | ||
12484 | @deftypevr {@code{prosody-configuration} parameter} file-name data-path | |
12485 | Location of the Prosody data storage directory. See | |
12486 | @url{http://prosody.im/doc/configure}. | |
12487 | Defaults to @samp{"/var/lib/prosody"}. | |
12488 | @end deftypevr | |
12489 | ||
12490 | @deftypevr {@code{prosody-configuration} parameter} file-name-list plugin-paths | |
12491 | Additional plugin directories. They are searched in all the specified | |
12492 | paths in order. See @url{http://prosody.im/doc/plugins_directory}. | |
12493 | Defaults to @samp{()}. | |
12494 | @end deftypevr | |
12495 | ||
12496 | @deftypevr {@code{prosody-configuration} parameter} string-list admins | |
12497 | This is a list of accounts that are admins for the server. Note that you | |
12498 | must create the accounts separately. See @url{http://prosody.im/doc/admins} and | |
12499 | @url{http://prosody.im/doc/creating_accounts}. | |
12500 | Example: @code{(admins '("user1@@example.com" "user2@@example.net"))} | |
12501 | Defaults to @samp{()}. | |
12502 | @end deftypevr | |
12503 | ||
12504 | @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent? | |
12505 | Enable use of libevent for better performance under high load. See | |
12506 | @url{http://prosody.im/doc/libevent}. | |
12507 | Defaults to @samp{#f}. | |
12508 | @end deftypevr | |
12509 | ||
12510 | @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled | |
12511 | This is the list of modules Prosody will load on startup. It looks for | |
12512 | @code{mod_modulename.lua} in the plugins folder, so make sure that exists too. | |
12513 | Documentation on modules can be found at: @url{http://prosody.im/doc/modules}. | |
12514 | Defaults to @samp{%default-modules-enabled}. | |
12515 | @end deftypevr | |
12516 | ||
12517 | @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled | |
12518 | @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but | |
12519 | should you want to disable them then add them to this list. | |
12520 | Defaults to @samp{()}. | |
12521 | @end deftypevr | |
12522 | ||
12523 | @deftypevr {@code{prosody-configuration} parameter} file-name groups-file | |
12524 | Path to a text file where the shared groups are defined. If this path is | |
12525 | empty then @samp{mod_groups} does nothing. See | |
12526 | @url{http://prosody.im/doc/modules/mod_groups}. | |
12527 | Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}. | |
12528 | @end deftypevr | |
12529 | ||
12530 | @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration? | |
12531 | Disable account creation by default, for security. See | |
12532 | @url{http://prosody.im/doc/creating_accounts}. | |
12533 | Defaults to @samp{#f}. | |
12534 | @end deftypevr | |
12535 | ||
12536 | @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl | |
12537 | These are the SSL/TLS-related settings. Most of them are disabled so to | |
12538 | use Prosody's defaults. If you do not completely understand these options, do | |
12539 | not add them to your config, it is easy to lower the security of your server | |
12540 | using them. See @url{http://prosody.im/doc/advanced_ssl_config}. | |
12541 | ||
12542 | Available @code{ssl-configuration} fields are: | |
12543 | ||
12544 | @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol | |
12545 | This determines what handshake to use. | |
12546 | @end deftypevr | |
12547 | ||
12548 | @deftypevr {@code{ssl-configuration} parameter} file-name key | |
12549 | Path to your private key file, relative to @code{/etc/prosody}. | |
12550 | Defaults to @samp{"/etc/prosody/certs/key.pem"}. | |
12551 | @end deftypevr | |
12552 | ||
12553 | @deftypevr {@code{ssl-configuration} parameter} file-name certificate | |
12554 | Path to your certificate file, relative to @code{/etc/prosody}. | |
12555 | Defaults to @samp{"/etc/prosody/certs/cert.pem"}. | |
12556 | @end deftypevr | |
12557 | ||
12558 | @deftypevr {@code{ssl-configuration} parameter} file-name capath | |
12559 | Path to directory containing root certificates that you wish Prosody to | |
12560 | trust when verifying the certificates of remote servers. | |
12561 | Defaults to @samp{"/etc/ssl/certs"}. | |
12562 | @end deftypevr | |
12563 | ||
12564 | @deftypevr {@code{ssl-configuration} parameter} maybe-file-name cafile | |
12565 | Path to a file containing root certificates that you wish Prosody to trust. | |
12566 | Similar to @code{capath} but with all certificates concatenated together. | |
12567 | @end deftypevr | |
12568 | ||
12569 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify | |
12570 | A list of verification options (these mostly map to OpenSSL's | |
12571 | @code{set_verify()} flags). | |
12572 | @end deftypevr | |
12573 | ||
12574 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options | |
12575 | A list of general options relating to SSL/TLS. These map to OpenSSL's | |
12576 | @code{set_options()}. For a full list of options available in LuaSec, see the | |
12577 | LuaSec source. | |
12578 | @end deftypevr | |
12579 | ||
12580 | @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth | |
12581 | How long a chain of certificate authorities to check when looking for a | |
12582 | trusted root certificate. | |
12583 | @end deftypevr | |
12584 | ||
12585 | @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers | |
12586 | An OpenSSL cipher string. This selects what ciphers Prosody will offer to | |
12587 | clients, and in what order. | |
12588 | @end deftypevr | |
12589 | ||
12590 | @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam | |
12591 | A path to a file containing parameters for Diffie-Hellman key exchange. You | |
12592 | can create such a file with: | |
12593 | @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048} | |
12594 | @end deftypevr | |
12595 | ||
12596 | @deftypevr {@code{ssl-configuration} parameter} maybe-string curve | |
12597 | Curve for Elliptic curve Diffie-Hellman. Prosody's default is | |
12598 | @samp{"secp384r1"}. | |
12599 | @end deftypevr | |
12600 | ||
12601 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext | |
12602 | A list of "extra" verification options. | |
12603 | @end deftypevr | |
12604 | ||
12605 | @deftypevr {@code{ssl-configuration} parameter} maybe-string password | |
12606 | Password for encrypted private keys. | |
12607 | @end deftypevr | |
12608 | ||
12609 | @end deftypevr | |
12610 | ||
12611 | @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption? | |
12612 | Whether to force all client-to-server connections to be encrypted or not. | |
12613 | See @url{http://prosody.im/doc/modules/mod_tls}. | |
12614 | Defaults to @samp{#f}. | |
12615 | @end deftypevr | |
12616 | ||
12617 | @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption? | |
12618 | Whether to force all server-to-server connections to be encrypted or not. | |
12619 | See @url{http://prosody.im/doc/modules/mod_tls}. | |
12620 | Defaults to @samp{#f}. | |
12621 | @end deftypevr | |
12622 | ||
12623 | @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth? | |
12624 | Whether to require encryption and certificate authentication. This | |
12625 | provides ideal security, but requires servers you communicate with to support | |
12626 | encryption AND present valid, trusted certificates. See | |
12627 | @url{http://prosody.im/doc/s2s#security}. | |
12628 | Defaults to @samp{#f}. | |
12629 | @end deftypevr | |
12630 | ||
12631 | @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains | |
12632 | Many servers don't support encryption or have invalid or self-signed | |
12633 | certificates. You can list domains here that will not be required to | |
12634 | authenticate using certificates. They will be authenticated using DNS. See | |
12635 | @url{http://prosody.im/doc/s2s#security}. | |
12636 | Defaults to @samp{()}. | |
12637 | @end deftypevr | |
12638 | ||
12639 | @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains | |
12640 | Even if you leave @code{s2s-secure-auth?} disabled, you can still require | |
12641 | valid certificates for some domains by specifying a list here. See | |
12642 | @url{http://prosody.im/doc/s2s#security}. | |
12643 | Defaults to @samp{()}. | |
12644 | @end deftypevr | |
12645 | ||
12646 | @deftypevr {@code{prosody-configuration} parameter} string authentication | |
12647 | Select the authentication backend to use. The default provider stores | |
12648 | passwords in plaintext and uses Prosody's configured data storage to store the | |
12649 | authentication data. If you do not trust your server please see | |
12650 | @url{http://prosody.im/doc/modules/mod_auth_internal_hashed} for information | |
12651 | about using the hashed backend. See also | |
12652 | @url{http://prosody.im/doc/authentication} | |
12653 | Defaults to @samp{"internal_plain"}. | |
12654 | @end deftypevr | |
12655 | ||
12656 | @deftypevr {@code{prosody-configuration} parameter} maybe-string log | |
12657 | Set logging options. Advanced logging configuration is not yet supported | |
12658 | by the GuixSD Prosody Service. See @url{http://prosody.im/doc/logging}. | |
12659 | Defaults to @samp{"*syslog"}. | |
12660 | @end deftypevr | |
12661 | ||
12662 | @deftypevr {@code{prosody-configuration} parameter} file-name pidfile | |
12663 | File to write pid in. See @url{http://prosody.im/doc/modules/mod_posix}. | |
12664 | Defaults to @samp{"/var/run/prosody/prosody.pid"}. | |
12665 | @end deftypevr | |
12666 | ||
12667 | @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts | |
12668 | A host in Prosody is a domain on which user accounts can be created. For | |
12669 | example if you want your users to have addresses like | |
12670 | @samp{"john.smith@@example.com"} then you need to add a host | |
12671 | @samp{"example.com"}. All options in this list will apply only to this host. | |
12672 | ||
12673 | Note: the name "virtual" host is used in configuration to avoid confusion with | |
12674 | the actual physical host that Prosody is installed on. A single Prosody | |
12675 | instance can serve many domains, each one defined as a VirtualHost entry in | |
12676 | Prosody's configuration. Conversely a server that hosts a single domain would | |
12677 | have just one VirtualHost entry. | |
12678 | ||
12679 | See @url{http://prosody.im/doc/configure#virtual_host_settings}. | |
12680 | ||
12681 | Available @code{virtualhost-configuration} fields are: | |
12682 | ||
12683 | 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: | |
12684 | @deftypevr {@code{virtualhost-configuration} parameter} string domain | |
12685 | Domain you wish Prosody to serve. | |
12686 | @end deftypevr | |
12687 | ||
12688 | @end deftypevr | |
12689 | ||
12690 | @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components | |
12691 | Components are extra services on a server which are available to clients, | |
12692 | usually on a subdomain of the main server (such as | |
12693 | @samp{"mycomponent.example.com"}). Example components might be chatroom | |
12694 | servers, user directories, or gateways to other protocols. | |
12695 | ||
12696 | Internal components are implemented with Prosody-specific plugins. To add an | |
12697 | internal component, you simply fill the hostname field, and the plugin you wish | |
12698 | to use for the component. | |
12699 | ||
12700 | See @url{http://prosody.im/doc/components}. | |
12701 | Defaults to @samp{()}. | |
12702 | ||
12703 | Available @code{int-component-configuration} fields are: | |
12704 | ||
12705 | 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: | |
12706 | @deftypevr {@code{int-component-configuration} parameter} string hostname | |
12707 | Hostname of the component. | |
12708 | @end deftypevr | |
12709 | ||
12710 | @deftypevr {@code{int-component-configuration} parameter} string plugin | |
12711 | Plugin you wish to use for the component. | |
12712 | @end deftypevr | |
12713 | ||
12714 | @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc | |
12715 | Multi-user chat (MUC) is Prosody's module for allowing you to create | |
12716 | hosted chatrooms/conferences for XMPP users. | |
12717 | ||
12718 | General information on setting up and using multi-user chatrooms can be found | |
12719 | in the "Chatrooms" documentation (@url{http://prosody.im/doc/chatrooms}), | |
12720 | which you should read if you are new to XMPP chatrooms. | |
12721 | ||
12722 | See also @url{http://prosody.im/doc/modules/mod_muc}. | |
12723 | ||
12724 | Available @code{mod-muc-configuration} fields are: | |
12725 | ||
12726 | @deftypevr {@code{mod-muc-configuration} parameter} string name | |
12727 | The name to return in service discovery responses. | |
12728 | Defaults to @samp{"Prosody Chatrooms"}. | |
12729 | @end deftypevr | |
12730 | ||
12731 | @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation | |
12732 | If @samp{#t}, this will only allow admins to create new chatrooms. | |
12733 | Otherwise anyone can create a room. The value @samp{"local"} restricts room | |
12734 | creation to users on the service's parent domain. E.g. @samp{user@@example.com} | |
12735 | can create rooms on @samp{rooms.example.com}. The value @samp{"admin"} | |
12736 | restricts to service administrators only. | |
12737 | Defaults to @samp{#f}. | |
12738 | @end deftypevr | |
12739 | ||
12740 | @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages | |
12741 | Maximum number of history messages that will be sent to the member that has | |
12742 | just joined the room. | |
12743 | Defaults to @samp{20}. | |
12744 | @end deftypevr | |
12745 | ||
12746 | @end deftypevr | |
12747 | ||
12748 | @end deftypevr | |
12749 | ||
12750 | @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components | |
12751 | External components use XEP-0114, which most standalone components | |
12752 | support. To add an external component, you simply fill the hostname field. See | |
12753 | @url{http://prosody.im/doc/components}. | |
12754 | Defaults to @samp{()}. | |
12755 | ||
12756 | Available @code{ext-component-configuration} fields are: | |
12757 | ||
12758 | 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: | |
12759 | @deftypevr {@code{ext-component-configuration} parameter} string component-secret | |
12760 | Password which the component will use to log in. | |
12761 | @end deftypevr | |
12762 | ||
12763 | @deftypevr {@code{ext-component-configuration} parameter} string hostname | |
12764 | Hostname of the component. | |
12765 | @end deftypevr | |
12766 | ||
12767 | @end deftypevr | |
12768 | ||
12769 | @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports | |
12770 | Port(s) Prosody listens on for component connections. | |
12771 | @end deftypevr | |
12772 | ||
12773 | @deftypevr {@code{prosody-configuration} parameter} string component-interface | |
12774 | Interface Prosody listens on for component connections. | |
12775 | Defaults to @samp{"127.0.0.1"}. | |
12776 | @end deftypevr | |
12777 | ||
12778 | It could be that you just want to get a @code{prosody.cfg.lua} | |
12779 | up and running. In that case, you can pass an | |
12780 | @code{opaque-prosody-configuration} record as the value of | |
12781 | @code{prosody-service-type}. As its name indicates, an opaque configuration | |
12782 | does not have easy reflective capabilities. | |
12783 | Available @code{opaque-prosody-configuration} fields are: | |
12784 | ||
12785 | @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody | |
12786 | The prosody package. | |
12787 | @end deftypevr | |
12788 | ||
12789 | @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua | |
12790 | The contents of the @code{prosody.cfg.lua} to use. | |
12791 | @end deftypevr | |
12792 | ||
12793 | For example, if your @code{prosody.cfg.lua} is just the empty | |
12794 | string, you could instantiate a prosody service like this: | |
12795 | ||
12796 | @example | |
12797 | (service prosody-service-type | |
12798 | (opaque-prosody-configuration | |
12799 | (prosody.cfg.lua ""))) | |
12800 | @end example | |
12801 | ||
859e367d JD |
12802 | @node Kerberos Services |
12803 | @subsubsection Kerberos Services | |
12804 | @cindex Kerberos | |
12805 | ||
df31e36a | 12806 | The @code{(gnu services kerberos)} module provides services relating to |
859e367d JD |
12807 | the authentication protocol @dfn{Kerberos}. |
12808 | ||
8e3f813f JD |
12809 | @subsubheading Krb5 Service |
12810 | ||
12811 | Programs using a Kerberos client library normally | |
12812 | expect a configuration file in @file{/etc/krb5.conf}. | |
12813 | This service generates such a file from a definition provided in the | |
12814 | operating system declaration. | |
12815 | It does not cause any daemon to be started. | |
12816 | ||
12817 | No ``keytab'' files are provided by this service---you must explicitly create them. | |
12818 | This service is known to work with the MIT client library, @code{mit-krb5}. | |
12819 | Other implementations have not been tested. | |
12820 | ||
12821 | @defvr {Scheme Variable} krb5-service-type | |
12822 | A service type for Kerberos 5 clients. | |
12823 | @end defvr | |
12824 | ||
12825 | @noindent | |
12826 | Here is an example of its use: | |
12827 | @lisp | |
12828 | (service krb5-service-type | |
12829 | (krb5-configuration | |
12830 | (default-realm "EXAMPLE.COM") | |
12831 | (allow-weak-crypto? #t) | |
12832 | (realms (list | |
12833 | (krb5-realm | |
12834 | (name "EXAMPLE.COM") | |
12835 | (admin-server "groucho.example.com") | |
12836 | (kdc "karl.example.com")) | |
12837 | (krb5-realm | |
12838 | (name "ARGRX.EDU") | |
12839 | (admin-server "kerb-admin.argrx.edu") | |
12840 | (kdc "keys.argrx.edu")))))) | |
12841 | @end lisp | |
12842 | ||
12843 | @noindent | |
12844 | This example provides a Kerberos@tie{}5 client configuration which: | |
12845 | @itemize | |
12846 | @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both | |
12847 | of which have distinct administration servers and key distribution centers; | |
12848 | @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly | |
12849 | specified by clients; | |
12850 | @item Accepts services which only support encryption types known to be weak. | |
12851 | @end itemize | |
12852 | ||
12853 | The @code{krb5-realm} and @code{krb5-configuration} types have many fields. | |
12854 | Only the most commonly used ones are described here. | |
12855 | For a full list, and more detailed explanation of each, see the MIT | |
12856 | @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf} | |
12857 | documentation. | |
12858 | ||
12859 | ||
12860 | @deftp {Data Type} krb5-realm | |
12861 | @cindex realm, kerberos | |
12862 | @table @asis | |
12863 | @item @code{name} | |
12864 | This field is a string identifying the name of the realm. | |
12865 | A common convention is to use the fully qualified DNS name of your organization, | |
12866 | converted to upper case. | |
12867 | ||
12868 | @item @code{admin-server} | |
12869 | This field is a string identifying the host where the administration server is | |
12870 | running. | |
12871 | ||
12872 | @item @code{kdc} | |
12873 | This field is a string identifying the key distribution center | |
12874 | for the realm. | |
12875 | @end table | |
12876 | @end deftp | |
12877 | ||
12878 | @deftp {Data Type} krb5-configuration | |
12879 | ||
12880 | @table @asis | |
12881 | @item @code{allow-weak-crypto?} (default: @code{#f}) | |
12882 | If this flag is @code{#t} then services which only offer encryption algorithms | |
12883 | known to be weak will be accepted. | |
12884 | ||
12885 | @item @code{default-realm} (default: @code{#f}) | |
12886 | This field should be a string identifying the default Kerberos | |
12887 | realm for the client. | |
12888 | You should set this field to the name of your Kerberos realm. | |
12889 | If this value is @code{#f} | |
12890 | then a realm must be specified with every Kerberos principal when invoking programs | |
12891 | such as @command{kinit}. | |
12892 | ||
12893 | @item @code{realms} | |
12894 | This should be a non-empty list of @code{krb5-realm} objects, which clients may | |
12895 | access. | |
12896 | Normally, one of them will have a @code{name} field matching the @code{default-realm} | |
12897 | field. | |
12898 | @end table | |
12899 | @end deftp | |
12900 | ||
12901 | ||
859e367d JD |
12902 | @subsubheading PAM krb5 Service |
12903 | @cindex pam-krb5 | |
12904 | ||
df31e36a | 12905 | The @code{pam-krb5} service allows for login authentication and password |
859e367d JD |
12906 | management via Kerberos. |
12907 | You will need this service if you want PAM enabled applications to authenticate | |
12908 | users using Kerberos. | |
12909 | ||
12910 | @defvr {Scheme Variable} pam-krb5-service-type | |
12911 | A service type for the Kerberos 5 PAM module. | |
12912 | @end defvr | |
12913 | ||
12914 | @deftp {Data Type} pam-krb5-configuration | |
12915 | Data type representing the configuration of the Kerberos 5 PAM module | |
12916 | This type has the following parameters: | |
12917 | @table @asis | |
12918 | @item @code{pam-krb5} (default: @code{pam-krb5}) | |
12919 | The pam-krb5 package to use. | |
12920 | ||
12921 | @item @code{minimum-uid} (default: @code{1000}) | |
12922 | The smallest user ID for which Kerberos authentications should be attempted. | |
12923 | Local accounts with lower values will silently fail to authenticate. | |
12924 | @end table | |
12925 | @end deftp | |
12926 | ||
12927 | ||
58724c48 DT |
12928 | @node Web Services |
12929 | @subsubsection Web Services | |
12930 | ||
e32171ee JD |
12931 | @cindex web |
12932 | @cindex www | |
12933 | @cindex HTTP | |
58724c48 DT |
12934 | The @code{(gnu services web)} module provides the following service: |
12935 | ||
be1c2c54 | 12936 | @deffn {Scheme Procedure} nginx-service [#:nginx nginx] @ |
58724c48 DT |
12937 | [#:log-directory ``/var/log/nginx''] @ |
12938 | [#:run-directory ``/var/run/nginx''] @ | |
d338237d | 12939 | [#:server-list '()] @ |
cb341293 | 12940 | [#:upstream-list '()] @ |
d338237d | 12941 | [#:config-file @code{#f}] |
58724c48 DT |
12942 | |
12943 | Return a service that runs @var{nginx}, the nginx web server. | |
12944 | ||
12945 | The nginx daemon loads its runtime configuration from @var{config-file}. | |
12946 | Log files are written to @var{log-directory} and temporary runtime data | |
12947 | files are written to @var{run-directory}. For proper operation, these | |
12948 | arguments should match what is in @var{config-file} to ensure that the | |
12949 | directories are created when the service is activated. | |
12950 | ||
3b9b12ef | 12951 | As an alternative to using a @var{config-file}, @var{server-list} can be |
cb341293 CB |
12952 | used to specify the list of @dfn{server blocks} required on the host and |
12953 | @var{upstream-list} can be used to specify a list of @dfn{upstream | |
12954 | blocks} to configure. For this to work, use the default value for | |
12955 | @var{config-file}. | |
8c00b838 | 12956 | |
58724c48 DT |
12957 | @end deffn |
12958 | ||
d338237d JL |
12959 | @deffn {Scheme Variable} nginx-service-type |
12960 | This is type for the nginx web server. | |
12961 | ||
12962 | This service can be extended to add server blocks in addition to the | |
12963 | default one, as in this example: | |
12964 | ||
12965 | @example | |
12966 | (simple-service 'my-extra-server nginx-service-type | |
12967 | (list (nginx-server-configuration | |
12968 | (https-port #f) | |
12969 | (root "/srv/http/extra-website")))) | |
12970 | @end example | |
12971 | @end deffn | |
12972 | ||
3b9b12ef JL |
12973 | @deftp {Data Type} nginx-server-configuration |
12974 | Data type representing the configuration of an nginx server block. | |
8c00b838 JL |
12975 | This type has the following parameters: |
12976 | ||
12977 | @table @asis | |
12978 | @item @code{http-port} (default: @code{80}) | |
12979 | Nginx will listen for HTTP connection on this port. Set it at @code{#f} if | |
12980 | nginx should not listen for HTTP (non secure) connection for this | |
3b9b12ef | 12981 | @dfn{server block}. |
8c00b838 JL |
12982 | |
12983 | @item @code{https-port} (default: @code{443}) | |
12984 | Nginx will listen for HTTPS connection on this port. Set it at @code{#f} if | |
3b9b12ef | 12985 | nginx should not listen for HTTPS (secure) connection for this @dfn{server block}. |
8c00b838 JL |
12986 | |
12987 | Note that nginx can listen for HTTP and HTTPS connections in the same | |
3b9b12ef | 12988 | @dfn{server block}. |
8c00b838 JL |
12989 | |
12990 | @item @code{server-name} (default: @code{(list 'default)}) | |
3b9b12ef JL |
12991 | A list of server names this server represents. @code{'default} represents the |
12992 | default server for connections matching no other server. | |
8c00b838 JL |
12993 | |
12994 | @item @code{root} (default: @code{"/srv/http"}) | |
12995 | Root of the website nginx will serve. | |
12996 | ||
9c557a69 CB |
12997 | @item @code{locations} (default: @code{'()}) |
12998 | A list of @dfn{nginx-location-configuration} or | |
12999 | @dfn{nginx-named-location-configuration} records to use within this | |
13000 | server block. | |
13001 | ||
8c00b838 JL |
13002 | @item @code{index} (default: @code{(list "index.html")}) |
13003 | Index files to look for when clients ask for a directory. If it cannot be found, | |
13004 | Nginx will send the list of files in the directory. | |
13005 | ||
13006 | @item @code{ssl-certificate} (default: @code{"/etc/nginx/cert.pem"}) | |
13007 | Where to find the certificate for secure connections. Set it to @code{#f} if | |
13008 | you don't have a certificate or you don't want to use HTTPS. | |
13009 | ||
13010 | @item @code{ssl-certificate-key} (default: @code{"/etc/nginx/key.pem"}) | |
13011 | Where to find the private key for secure connections. Set it to @code{#f} if | |
13012 | you don't have a key or you don't want to use HTTPS. | |
13013 | ||
13014 | @item @code{server-tokens?} (default: @code{#f}) | |
13015 | Whether the server should add its configuration to response. | |
13016 | ||
13017 | @end table | |
13018 | @end deftp | |
13019 | ||
2be1b471 JL |
13020 | @node VPN Services |
13021 | @subsubsection VPN Services | |
13022 | @cindex VPN (virtual private network) | |
13023 | @cindex virtual private network (VPN) | |
13024 | ||
13025 | The @code{(gnu services vpn)} module provides services related to | |
13026 | @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for | |
13027 | your machine to connect to a VPN, and a @emph{servire} service for your machine | |
13028 | to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}. | |
13029 | ||
13030 | @deffn {Scheme Procedure} openvpn-client-service @ | |
13031 | [#:config (openvpn-client-configuration)] | |
13032 | ||
13033 | Return a service that runs @command{openvpn}, a VPN daemon, as a client. | |
13034 | @end deffn | |
13035 | ||
13036 | @deffn {Scheme Procedure} openvpn-server-service @ | |
13037 | [#:config (openvpn-server-configuration)] | |
13038 | ||
13039 | Return a service that runs @command{openvpn}, a VPN daemon, as a server. | |
13040 | ||
13041 | Both can be run simultaneously. | |
13042 | @end deffn | |
13043 | ||
13044 | @c %automatically generated documentation | |
13045 | ||
13046 | Available @code{openvpn-client-configuration} fields are: | |
13047 | ||
13048 | @deftypevr @code{openvpn-client-configuration} parameter package openvpn | |
13049 | The OpenVPN package. | |
13050 | ||
13051 | @end deftypevr | |
13052 | ||
13053 | @deftypevr @code{openvpn-client-configuration} parameter string pid-file | |
13054 | The OpenVPN pid file. | |
13055 | ||
13056 | Defaults to @samp{"/var/run/openvpn/openvpn.pid"}. | |
13057 | ||
13058 | @end deftypevr | |
13059 | ||
13060 | @deftypevr @code{openvpn-client-configuration} parameter proto proto | |
13061 | The protocol (UDP or TCP) used to open a channel between clients and | |
13062 | servers. | |
13063 | ||
13064 | Defaults to @samp{udp}. | |
13065 | ||
13066 | @end deftypevr | |
13067 | ||
13068 | @deftypevr @code{openvpn-client-configuration} parameter dev dev | |
13069 | The device type used to represent the VPN connection. | |
13070 | ||
13071 | Defaults to @samp{tun}. | |
13072 | ||
13073 | @end deftypevr | |
13074 | ||
13075 | @deftypevr @code{openvpn-client-configuration} parameter string ca | |
13076 | The certificate authority to check connections against. | |
13077 | ||
13078 | Defaults to @samp{"/etc/openvpn/ca.crt"}. | |
13079 | ||
13080 | @end deftypevr | |
13081 | ||
13082 | @deftypevr @code{openvpn-client-configuration} parameter string cert | |
13083 | The certificate of the machine the daemon is running on. It should be | |
13084 | signed by the authority given in @code{ca}. | |
13085 | ||
13086 | Defaults to @samp{"/etc/openvpn/client.crt"}. | |
13087 | ||
13088 | @end deftypevr | |
13089 | ||
13090 | @deftypevr @code{openvpn-client-configuration} parameter string key | |
13091 | The key of the machine the daemon is running on. It must be the key whose | |
13092 | certificate is @code{cert}. | |
13093 | ||
13094 | Defaults to @samp{"/etc/openvpn/client.key"}. | |
13095 | ||
13096 | @end deftypevr | |
13097 | ||
13098 | @deftypevr @code{openvpn-client-configuration} parameter boolean comp-lzo? | |
13099 | Whether to use the lzo compression algorithm. | |
13100 | ||
13101 | Defaults to @samp{#t}. | |
13102 | ||
13103 | @end deftypevr | |
13104 | ||
13105 | @deftypevr @code{openvpn-client-configuration} parameter boolean persist-key? | |
13106 | Don't re-read key files across SIGUSR1 or --ping-restart. | |
13107 | ||
13108 | Defaults to @samp{#t}. | |
13109 | ||
13110 | @end deftypevr | |
13111 | ||
13112 | @deftypevr @code{openvpn-client-configuration} parameter boolean persist-tun? | |
13113 | Don't close and reopen TUN/TAP device or run up/down scripts across | |
13114 | SIGUSR1 or --ping-restart restarts. | |
13115 | ||
13116 | Defaults to @samp{#t}. | |
13117 | ||
13118 | @end deftypevr | |
13119 | ||
13120 | @deftypevr @code{openvpn-client-configuration} parameter number verbosity | |
13121 | Verbosity level. | |
13122 | ||
13123 | Defaults to @samp{3}. | |
13124 | ||
13125 | @end deftypevr | |
13126 | ||
13127 | @deftypevr @code{openvpn-client-configuration} parameter tls-auth-client tls-auth | |
13128 | Add an additional layer of HMAC authentication on top of the TLS control | |
13129 | channel to protect against DoS attacks. | |
13130 | ||
13131 | Defaults to @samp{#f}. | |
13132 | ||
13133 | @end deftypevr | |
13134 | ||
13135 | @deftypevr @code{openvpn-client-configuration} parameter key-usage verify-key-usage? | |
13136 | Whether to check the server certificate has server usage extension. | |
13137 | ||
13138 | Defaults to @samp{#t}. | |
13139 | ||
13140 | @end deftypevr | |
13141 | ||
13142 | @deftypevr @code{openvpn-client-configuration} parameter bind bind? | |
13143 | Bind to a specific local port number. | |
13144 | ||
13145 | Defaults to @samp{#f}. | |
13146 | ||
13147 | @end deftypevr | |
13148 | ||
13149 | @deftypevr @code{openvpn-client-configuration} parameter resolv-retry resolv-retry? | |
13150 | Retry resolving server address. | |
13151 | ||
13152 | Defaults to @samp{#t}. | |
13153 | ||
13154 | @end deftypevr | |
13155 | ||
13156 | @deftypevr @code{openvpn-client-configuration} parameter openvpn-remote-list remote | |
13157 | A list of remote servers to connect to. | |
13158 | ||
13159 | Defaults to @samp{()}. | |
13160 | ||
13161 | Available @code{openvpn-remote-configuration} fields are: | |
13162 | ||
13163 | @deftypevr @code{openvpn-remote-configuration} parameter string name | |
13164 | Server name. | |
13165 | ||
13166 | Defaults to @samp{"my-server"}. | |
13167 | ||
13168 | @end deftypevr | |
13169 | ||
13170 | @deftypevr @code{openvpn-remote-configuration} parameter number port | |
13171 | Port number the server listens to. | |
13172 | ||
13173 | Defaults to @samp{1194}. | |
13174 | ||
13175 | @end deftypevr | |
13176 | ||
13177 | @end deftypevr | |
13178 | @c %end of automatic openvpn-client documentation | |
13179 | ||
13180 | @c %automatically generated documentation | |
13181 | ||
13182 | Available @code{openvpn-server-configuration} fields are: | |
13183 | ||
13184 | @deftypevr @code{openvpn-server-configuration} parameter package openvpn | |
13185 | The OpenVPN package. | |
13186 | ||
13187 | @end deftypevr | |
13188 | ||
13189 | @deftypevr @code{openvpn-server-configuration} parameter string pid-file | |
13190 | The OpenVPN pid file. | |
13191 | ||
13192 | Defaults to @samp{"/var/run/openvpn/openvpn.pid"}. | |
13193 | ||
13194 | @end deftypevr | |
13195 | ||
13196 | @deftypevr @code{openvpn-server-configuration} parameter proto proto | |
13197 | The protocol (UDP or TCP) used to open a channel between clients and | |
13198 | servers. | |
13199 | ||
13200 | Defaults to @samp{udp}. | |
13201 | ||
13202 | @end deftypevr | |
13203 | ||
13204 | @deftypevr @code{openvpn-server-configuration} parameter dev dev | |
13205 | The device type used to represent the VPN connection. | |
13206 | ||
13207 | Defaults to @samp{tun}. | |
13208 | ||
13209 | @end deftypevr | |
13210 | ||
13211 | @deftypevr @code{openvpn-server-configuration} parameter string ca | |
13212 | The certificate authority to check connections against. | |
13213 | ||
13214 | Defaults to @samp{"/etc/openvpn/ca.crt"}. | |
13215 | ||
13216 | @end deftypevr | |
13217 | ||
13218 | @deftypevr @code{openvpn-server-configuration} parameter string cert | |
13219 | The certificate of the machine the daemon is running on. It should be | |
13220 | signed by the authority given in @code{ca}. | |
13221 | ||
13222 | Defaults to @samp{"/etc/openvpn/client.crt"}. | |
13223 | ||
13224 | @end deftypevr | |
13225 | ||
13226 | @deftypevr @code{openvpn-server-configuration} parameter string key | |
13227 | The key of the machine the daemon is running on. It must be the key whose | |
13228 | certificate is @code{cert}. | |
13229 | ||
13230 | Defaults to @samp{"/etc/openvpn/client.key"}. | |
13231 | ||
13232 | @end deftypevr | |
13233 | ||
13234 | @deftypevr @code{openvpn-server-configuration} parameter boolean comp-lzo? | |
13235 | Whether to use the lzo compression algorithm. | |
13236 | ||
13237 | Defaults to @samp{#t}. | |
13238 | ||
13239 | @end deftypevr | |
13240 | ||
13241 | @deftypevr @code{openvpn-server-configuration} parameter boolean persist-key? | |
13242 | Don't re-read key files across SIGUSR1 or --ping-restart. | |
13243 | ||
13244 | Defaults to @samp{#t}. | |
13245 | ||
13246 | @end deftypevr | |
13247 | ||
13248 | @deftypevr @code{openvpn-server-configuration} parameter boolean persist-tun? | |
13249 | Don't close and reopen TUN/TAP device or run up/down scripts across | |
13250 | SIGUSR1 or --ping-restart restarts. | |
13251 | ||
13252 | Defaults to @samp{#t}. | |
13253 | ||
13254 | @end deftypevr | |
13255 | ||
13256 | @deftypevr @code{openvpn-server-configuration} parameter number verbosity | |
13257 | Verbosity level. | |
13258 | ||
13259 | Defaults to @samp{3}. | |
13260 | ||
13261 | @end deftypevr | |
13262 | ||
13263 | @deftypevr @code{openvpn-server-configuration} parameter tls-auth-server tls-auth | |
13264 | Add an additional layer of HMAC authentication on top of the TLS control | |
13265 | channel to protect against DoS attacks. | |
13266 | ||
13267 | Defaults to @samp{#f}. | |
13268 | ||
13269 | @end deftypevr | |
13270 | ||
13271 | @deftypevr @code{openvpn-server-configuration} parameter number port | |
13272 | Specifies the port number on which the server listens. | |
13273 | ||
13274 | Defaults to @samp{1194}. | |
13275 | ||
13276 | @end deftypevr | |
13277 | ||
13278 | @deftypevr @code{openvpn-server-configuration} parameter ip-mask server | |
13279 | An ip and mask specifying the subnet inside the virtual network. | |
13280 | ||
13281 | Defaults to @samp{"10.8.0.0 255.255.255.0"}. | |
13282 | ||
13283 | @end deftypevr | |
13284 | ||
13285 | @deftypevr @code{openvpn-server-configuration} parameter cidr6 server-ipv6 | |
13286 | A CIDR notation specifying the IPv6 subnet inside the virtual network. | |
13287 | ||
13288 | Defaults to @samp{#f}. | |
13289 | ||
13290 | @end deftypevr | |
13291 | ||
13292 | @deftypevr @code{openvpn-server-configuration} parameter string dh | |
13293 | The Diffie-Hellman parameters file. | |
13294 | ||
13295 | Defaults to @samp{"/etc/openvpn/dh2048.pem"}. | |
13296 | ||
13297 | @end deftypevr | |
13298 | ||
13299 | @deftypevr @code{openvpn-server-configuration} parameter string ifconfig-pool-persist | |
13300 | The file that records client IPs. | |
13301 | ||
13302 | Defaults to @samp{"/etc/openvpn/ipp.txt"}. | |
13303 | ||
13304 | @end deftypevr | |
13305 | ||
13306 | @deftypevr @code{openvpn-server-configuration} parameter gateway redirect-gateway? | |
13307 | When true, the server will act as a gateway for its clients. | |
13308 | ||
13309 | Defaults to @samp{#f}. | |
13310 | ||
13311 | @end deftypevr | |
13312 | ||
13313 | @deftypevr @code{openvpn-server-configuration} parameter boolean client-to-client? | |
13314 | When true, clients are alowed to talk to each other inside the VPN. | |
13315 | ||
13316 | Defaults to @samp{#f}. | |
13317 | ||
13318 | @end deftypevr | |
13319 | ||
13320 | @deftypevr @code{openvpn-server-configuration} parameter keepalive keepalive | |
13321 | Causes ping-like messages to be sent back and forth over the link so | |
13322 | that each side knows when the other side has gone down. @code{keepalive} | |
13323 | requires a pair. The first element is the period of the ping sending, | |
13324 | and the second element is the timeout before considering the other side | |
13325 | down. | |
13326 | ||
13327 | @end deftypevr | |
13328 | ||
13329 | @deftypevr @code{openvpn-server-configuration} parameter number max-clients | |
13330 | The maximum number of clients. | |
13331 | ||
13332 | Defaults to @samp{100}. | |
13333 | ||
13334 | @end deftypevr | |
13335 | ||
13336 | @deftypevr @code{openvpn-server-configuration} parameter string status | |
13337 | The status file. This file shows a small report on current connection. | |
13338 | It is trunkated and rewritten every minute. | |
13339 | ||
13340 | Defaults to @samp{"/var/run/openvpn/status"}. | |
13341 | ||
13342 | @end deftypevr | |
13343 | ||
13344 | @deftypevr @code{openvpn-server-configuration} parameter openvpn-ccd-list client-config-dir | |
13345 | The list of configuration for some clients. | |
13346 | ||
13347 | Defaults to @samp{()}. | |
13348 | ||
13349 | Available @code{openvpn-ccd-configuration} fields are: | |
13350 | ||
13351 | @deftypevr @code{openvpn-ccd-configuration} parameter string name | |
13352 | Client name. | |
13353 | ||
13354 | Defaults to @samp{"client"}. | |
13355 | ||
13356 | @end deftypevr | |
13357 | ||
13358 | @deftypevr @code{openvpn-ccd-configuration} parameter ip-mask iroute | |
13359 | Client own network | |
13360 | ||
13361 | Defaults to @samp{#f}. | |
13362 | ||
13363 | @end deftypevr | |
13364 | ||
13365 | @deftypevr @code{openvpn-ccd-configuration} parameter ip-mask ifconfig-push | |
13366 | Client VPN IP. | |
13367 | ||
13368 | Defaults to @samp{#f}. | |
13369 | ||
13370 | @end deftypevr | |
13371 | ||
13372 | @end deftypevr | |
13373 | ||
13374 | ||
13375 | @c %end of automatic openvpn-server documentation | |
13376 | ||
13377 | ||
cb341293 CB |
13378 | @deftp {Data Type} nginx-upstream-configuration |
13379 | Data type representing the configuration of an nginx @code{upstream} | |
13380 | block. This type has the following parameters: | |
13381 | ||
13382 | @table @asis | |
13383 | @item @code{name} | |
13384 | Name for this group of servers. | |
13385 | ||
13386 | @item @code{servers} | |
13387 | Specify the addresses of the servers in the group. The address can be | |
13388 | specified as a IP address (e.g. @samp{127.0.0.1}), domain name | |
13389 | (e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the | |
13390 | prefix @samp{unix:}. For addresses using an IP address or domain name, | |
13391 | the default port is 80, and a different port can be specified | |
13392 | explicitly. | |
13393 | ||
13394 | @end table | |
13395 | @end deftp | |
13396 | ||
9c557a69 CB |
13397 | @deftp {Data Type} nginx-location-configuration |
13398 | Data type representing the configuration of an nginx @code{location} | |
13399 | block. This type has the following parameters: | |
13400 | ||
13401 | @table @asis | |
13402 | @item @code{uri} | |
13403 | URI which this location block matches. | |
13404 | ||
13405 | @anchor{nginx-location-configuration body} | |
13406 | @item @code{body} | |
13407 | Body of the location block, specified as a string. This can contain many | |
13408 | configuration directives. For example, to pass requests to a upstream | |
13409 | server group defined using an @code{nginx-upstream-configuration} block, | |
13410 | the following directive would be specified in the body @samp{proxy_pass | |
13411 | http://upstream-name;}. | |
13412 | ||
13413 | @end table | |
13414 | @end deftp | |
13415 | ||
13416 | @deftp {Data Type} nginx-named-location-configuration | |
13417 | Data type representing the configuration of an nginx named location | |
13418 | block. Named location blocks are used for request redirection, and not | |
13419 | used for regular request processing. This type has the following | |
13420 | parameters: | |
13421 | ||
13422 | @table @asis | |
13423 | @item @code{name} | |
13424 | Name to identify this location block. | |
13425 | ||
13426 | @item @code{body} | |
13427 | @xref{nginx-location-configuration body}, as the body for named location | |
13428 | blocks can be used in a similar way to the | |
13429 | @code{nginx-location-configuration body}. One restriction is that the | |
13430 | body of a named location block cannot contain location blocks. | |
13431 | ||
13432 | @end table | |
13433 | @end deftp | |
13434 | ||
eb419bc9 JD |
13435 | @node Network File System |
13436 | @subsubsection Network File System | |
13437 | @cindex NFS | |
fe1a39d3 | 13438 | |
eb419bc9 JD |
13439 | The @code{(gnu services nfs)} module provides the following services, |
13440 | which are most commonly used in relation to mounting or exporting | |
13441 | directory trees as @dfn{network file systems} (NFS). | |
d6a07ee6 JD |
13442 | |
13443 | @subsubheading RPC Bind Service | |
13444 | @cindex rpcbind | |
13445 | ||
eb419bc9 JD |
13446 | The RPC Bind service provides a facility to map program numbers into |
13447 | universal addresses. | |
13448 | Many NFS related services use this facility. Hence it is automatically | |
13449 | started when a dependent service starts. | |
d6a07ee6 JD |
13450 | |
13451 | @defvr {Scheme Variable} rpcbind-service-type | |
13452 | A service type for the RPC portmapper daemon. | |
13453 | @end defvr | |
13454 | ||
13455 | ||
13456 | @deftp {Data Type} rpcbind-configuration | |
13457 | Data type representing the configuration of the RPC Bind Service. | |
13458 | This type has the following parameters: | |
13459 | @table @asis | |
13460 | @item @code{rpcbind} (default: @code{rpcbind}) | |
13461 | The rpcbind package to use. | |
13462 | ||
13463 | @item @code{warm-start?} (default: @code{#t}) | |
13464 | If this parameter is @code{#t}, then the daemon will read a | |
13465 | state file on startup thus reloading state information saved by a previous | |
13466 | instance. | |
13467 | @end table | |
13468 | @end deftp | |
13469 | ||
eb419bc9 JD |
13470 | |
13471 | @subsubheading Pipefs Pseudo File System | |
13472 | @cindex pipefs | |
13473 | @cindex rpc_pipefs | |
13474 | ||
13475 | The pipefs file system is used to transfer NFS related data | |
13476 | between the kernel and user space programs. | |
13477 | ||
13478 | @defvr {Scheme Variable} pipefs-service-type | |
13479 | A service type for the pipefs pseudo file system. | |
13480 | @end defvr | |
13481 | ||
13482 | @deftp {Data Type} pipefs-configuration | |
13483 | Data type representing the configuration of the pipefs pseudo file system service. | |
13484 | This type has the following parameters: | |
13485 | @table @asis | |
13486 | @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13487 | The directory to which the file system is to be attached. | |
13488 | @end table | |
13489 | @end deftp | |
13490 | ||
13491 | ||
13492 | @subsubheading GSS Daemon Service | |
13493 | @cindex GSSD | |
13494 | @cindex GSS | |
13495 | @cindex global security system | |
13496 | ||
13497 | The @dfn{global security system} (GSS) daemon provides strong security for RPC | |
13498 | based protocols. | |
13499 | Before exchanging RPC requests an RPC client must establish a security | |
13500 | context. Typically this is done using the Kerberos command @command{kinit} | |
859e367d | 13501 | or automatically at login time using PAM services (@pxref{Kerberos Services}). |
eb419bc9 JD |
13502 | |
13503 | @defvr {Scheme Variable} gss-service-type | |
13504 | A service type for the Global Security System (GSS) daemon. | |
13505 | @end defvr | |
13506 | ||
13507 | @deftp {Data Type} gss-configuration | |
13508 | Data type representing the configuration of the GSS daemon service. | |
13509 | This type has the following parameters: | |
13510 | @table @asis | |
13511 | @item @code{nfs-utils} (default: @code{nfs-utils}) | |
13512 | The package in which the @command{rpc.gssd} command is to be found. | |
13513 | ||
13514 | @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13515 | The directory where the pipefs file system is mounted. | |
13516 | ||
13517 | @end table | |
13518 | @end deftp | |
13519 | ||
13520 | ||
13521 | @subsubheading IDMAP Daemon Service | |
13522 | @cindex idmapd | |
13523 | @cindex name mapper | |
13524 | ||
13525 | The idmap daemon service provides mapping between user IDs and user names. | |
13526 | Typically it is required in order to access file systems mounted via NFSv4. | |
13527 | ||
13528 | @defvr {Scheme Variable} idmap-service-type | |
13529 | A service type for the Identity Mapper (IDMAP) daemon. | |
13530 | @end defvr | |
13531 | ||
13532 | @deftp {Data Type} idmap-configuration | |
13533 | Data type representing the configuration of the IDMAP daemon service. | |
13534 | This type has the following parameters: | |
13535 | @table @asis | |
13536 | @item @code{nfs-utils} (default: @code{nfs-utils}) | |
13537 | The package in which the @command{rpc.idmapd} command is to be found. | |
13538 | ||
13539 | @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13540 | The directory where the pipefs file system is mounted. | |
13541 | ||
13542 | @item @code{domain} (default: @code{#f}) | |
13543 | The local NFSv4 domain name. | |
13544 | This must be a string or @code{#f}. | |
13545 | If it is @code{#f} then the daemon will use the host's fully qualified domain name. | |
13546 | ||
13547 | @end table | |
13548 | @end deftp | |
13549 | ||
a7cf4eb6 ML |
13550 | @node Continuous Integration |
13551 | @subsubsection Continuous Integration | |
13552 | ||
13553 | @cindex continuous integration | |
13554 | @uref{https://notabug.org/mthl/cuirass, Cuirass} is a continuous | |
13555 | integration tool for Guix. It can be used both for development and for | |
13556 | providing substitutes to others (@pxref{Substitutes}). | |
13557 | ||
13558 | The @code{(gnu services cuirass)} module provides the following service. | |
13559 | ||
231eddc8 LC |
13560 | @defvr {Scheme Procedure} cuirass-service-type |
13561 | The type of the Cuirass service. Its value must be a | |
13562 | @code{cuirass-configuration} object, as described below. | |
13563 | @end defvr | |
a7cf4eb6 | 13564 | |
231eddc8 LC |
13565 | To add build jobs, you have to set the @code{specifications} field of |
13566 | the configuration. Here is an example of a service defining a build job | |
13567 | based on a specification that can be found in Cuirass source tree. This | |
13568 | service polls the Guix repository and builds a subset of the Guix | |
13569 | packages, as prescribed in the @file{gnu-system.scm} example spec: | |
a7cf4eb6 ML |
13570 | |
13571 | @example | |
8de938d5 LC |
13572 | (let ((spec #~((#:name . "guix") |
13573 | (#:url . "git://git.savannah.gnu.org/guix.git") | |
13574 | (#:load-path . ".") | |
13575 | ||
13576 | ;; Here we must provide an absolute file name. | |
13577 | ;; We take jobs from one of the examples provided | |
13578 | ;; by Cuirass. | |
13579 | (#:file . #$(file-append | |
13580 | cuirass | |
13581 | "/tests/gnu-system.scm")) | |
13582 | ||
13583 | (#:proc . hydra-jobs) | |
13584 | (#:arguments (subset . "hello")) | |
13585 | (#:branch . "master")))) | |
231eddc8 LC |
13586 | (service cuirass-service-type |
13587 | (cuirass-configuration | |
13588 | (specifications #~(list #$spec))))) | |
a7cf4eb6 ML |
13589 | @end example |
13590 | ||
231eddc8 | 13591 | While information related to build jobs is located directly in the |
a7cf4eb6 ML |
13592 | specifications, global settings for the @command{cuirass} process are |
13593 | accessible in other @code{cuirass-configuration} fields. | |
13594 | ||
13595 | @deftp {Data Type} cuirass-configuration | |
13596 | Data type representing the configuration of Cuirass. | |
13597 | ||
13598 | @table @asis | |
b17e326f LC |
13599 | @item @code{log-file} (default: @code{"/var/log/cuirass.log"}) |
13600 | Location of the log file. | |
13601 | ||
463995da | 13602 | @item @code{cache-directory} (default: @code{"/var/cache/cuirass"}) |
a7cf4eb6 ML |
13603 | Location of the repository cache. |
13604 | ||
13605 | @item @code{user} (default: @code{"cuirass"}) | |
13606 | Owner of the @code{cuirass} process. | |
13607 | ||
13608 | @item @code{group} (default: @code{"cuirass"}) | |
13609 | Owner's group of the @code{cuirass} process. | |
13610 | ||
13611 | @item @code{interval} (default: @code{60}) | |
13612 | Number of seconds between the poll of the repositories followed by the | |
13613 | Cuirass jobs. | |
13614 | ||
13615 | @item @code{database} (default: @code{"/var/run/cuirass/cuirass.db"}) | |
13616 | Location of sqlite database which contains the build results and previously | |
13617 | added specifications. | |
13618 | ||
11b7717d MO |
13619 | @item @code{port} (default: @code{8080}) |
13620 | Port number used by the HTTP server. | |
13621 | ||
8de938d5 LC |
13622 | @item @code{specifications} (default: @code{#~'()}) |
13623 | A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications, | |
13624 | where a specification is an association list | |
a7cf4eb6 ML |
13625 | (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose |
13626 | keys are keywords (@code{#:keyword-example}) as shown in the example | |
13627 | above. | |
13628 | ||
13629 | @item @code{use-substitutes?} (default: @code{#f}) | |
13630 | This allows using substitutes to avoid building every dependencies of a job | |
13631 | from source. | |
13632 | ||
13633 | @item @code{one-shot?} (default: @code{#f}) | |
13634 | Only evaluate specifications and build derivations once. | |
379b6ba5 | 13635 | |
eb122280 MO |
13636 | @item @code{load-path} (default: @code{'()}) |
13637 | This allows users to define their own packages and make them visible to | |
13638 | cuirass as in @command{guix build} command. | |
13639 | ||
379b6ba5 LC |
13640 | @item @code{cuirass} (default: @code{cuirass}) |
13641 | The Cuirass package to use. | |
a7cf4eb6 ML |
13642 | @end table |
13643 | @end deftp | |
eb419bc9 JD |
13644 | |
13645 | @node Miscellaneous Services | |
13646 | @subsubsection Miscellaneous Services | |
13647 | ||
13648 | ||
8ff4dcbe DC |
13649 | @cindex lirc |
13650 | @subsubheading Lirc Service | |
13651 | ||
fe1a39d3 LC |
13652 | The @code{(gnu services lirc)} module provides the following service. |
13653 | ||
be1c2c54 | 13654 | @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @ |
fe1a39d3 LC |
13655 | [#:device #f] [#:driver #f] [#:config-file #f] @ |
13656 | [#:extra-options '()] | |
13657 | Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that | |
13658 | decodes infrared signals from remote controls. | |
13659 | ||
13660 | Optionally, @var{device}, @var{driver} and @var{config-file} | |
13661 | (configuration file name) may be specified. See @command{lircd} manual | |
13662 | for details. | |
13663 | ||
13664 | Finally, @var{extra-options} is a list of additional command-line options | |
13665 | passed to @command{lircd}. | |
13666 | @end deffn | |
13667 | ||
00f46905 DC |
13668 | @cindex spice |
13669 | @subsubheading Spice Service | |
13670 | ||
13671 | The @code{(gnu services spice)} module provides the following service. | |
13672 | ||
13673 | @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent] | |
13674 | Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon | |
13675 | that enables sharing the clipboard with a vm and setting the guest display | |
13676 | resolution when the graphical console window resizes. | |
13677 | @end deffn | |
13678 | ||
c3d38b2b | 13679 | @subsubsection Dictionary Services |
e32171ee | 13680 | @cindex dictionary |
c3d38b2b SB |
13681 | The @code{(gnu services dict)} module provides the following service: |
13682 | ||
13683 | @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)] | |
13684 | Return a service that runs the @command{dicod} daemon, an implementation | |
13685 | of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}). | |
13686 | ||
13687 | The optional @var{config} argument specifies the configuration for | |
13688 | @command{dicod}, which should be a @code{<dicod-configuration>} object, by | |
13689 | default it serves the GNU Collaborative International Dictonary of English. | |
13690 | ||
13691 | You can add @command{open localhost} to your @file{~/.dico} file to make | |
13692 | @code{localhost} the default server for @command{dico} client | |
13693 | (@pxref{Initialization File,,, dico, GNU Dico Manual}). | |
13694 | @end deffn | |
13695 | ||
13696 | @deftp {Data Type} dicod-configuration | |
13697 | Data type representing the configuration of dicod. | |
13698 | ||
13699 | @table @asis | |
13700 | @item @code{dico} (default: @var{dico}) | |
13701 | Package object of the GNU Dico dictionary server. | |
13702 | ||
a1b48465 LC |
13703 | @item @code{interfaces} (default: @var{'("localhost")}) |
13704 | This is the list of IP addresses and ports and possibly socket file | |
13705 | names to listen to (@pxref{Server Settings, @code{listen} directive,, | |
13706 | dico, GNU Dico Manual}). | |
13707 | ||
c3d38b2b SB |
13708 | @item @code{databases} (default: @var{(list %dicod-database:gcide)}) |
13709 | List of @code{<dicod-database>} objects denoting dictionaries to be served. | |
13710 | @end table | |
13711 | @end deftp | |
13712 | ||
13713 | @deftp {Data Type} dicod-database | |
13714 | Data type representing a dictionary database. | |
13715 | ||
13716 | @table @asis | |
13717 | @item @code{name} | |
13718 | Name of the database, will be used in DICT commands. | |
13719 | ||
13720 | @item @code{module} | |
13721 | Name of the dicod module used by this database | |
13722 | (@pxref{Modules,,, dico, GNU Dico Manual}). | |
13723 | ||
13724 | @item @code{options} | |
13725 | List of strings or gexps representing the arguments for the module handler | |
13726 | (@pxref{Handlers,,, dico, GNU Dico Manual}). | |
13727 | @end table | |
13728 | @end deftp | |
13729 | ||
13730 | @defvr {Scheme Variable} %dicod-database:gcide | |
13731 | A @code{<dicod-database>} object serving the GNU Collaborative International | |
13732 | Dictonary of English using the @code{gcide} package. | |
13733 | @end defvr | |
fe1a39d3 | 13734 | |
e01e2c6c | 13735 | @subsubsection Version Control |
13736 | ||
13737 | The @code{(gnu services version-control)} module provides the following services: | |
13738 | ||
13739 | @subsubheading Git daemon service | |
13740 | ||
13741 | @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)] | |
13742 | ||
13743 | Return a service that runs @command{git daemon}, a simple TCP server to | |
13744 | expose repositiories over the Git protocol for annoymous access. | |
13745 | ||
13746 | The optional @var{config} argument should be a | |
13747 | @code{<git-daemon-configuration>} object, by default it allows read-only | |
13748 | access to exported@footnote{By creating the magic file | |
13749 | "git-daemon-export-ok" in the repository directory.} repositories under | |
13750 | @file{/srv/git}. | |
13751 | ||
13752 | @end deffn | |
13753 | ||
13754 | @deftp {Data Type} git-daemon-configuration | |
13755 | Data type representing the configuration for @code{git-daemon-service}. | |
13756 | ||
13757 | @table @asis | |
13758 | @item @code{package} (default: @var{git}) | |
13759 | Package object of the Git distributed version control system. | |
13760 | ||
13761 | @item @code{export-all?} (default: @var{#f}) | |
13762 | Whether to allow access for all Git repositories, even if they do not | |
13763 | have the @file{git-daemon-export-ok} file. | |
13764 | ||
13765 | @item @code{base-path} (default: @file{/srv/git}) | |
13766 | Whether to remap all the path requests as relative to the given path. | |
13767 | If you run git daemon with @var{(base-path "/srv/git")} on example.com, | |
13768 | then if you later try to pull @code{git://example.com/hello.git}, git | |
13769 | daemon will interpret the path as @code{/srv/git/hello.git}. | |
13770 | ||
13771 | @item @code{user-path} (default: @var{#f}) | |
13772 | Whether to allow @code{~user} notation to be used in requests. When | |
13773 | specified with empty string, requests to @code{git://host/~alice/foo} is | |
13774 | taken as a request to access @code{foo} repository in the home directory | |
13775 | of user @code{alice}. If @var{(user-path "path")} is specified, the | |
13776 | same request is taken as a request to access @code{path/foo} repository | |
13777 | in the home directory of user @code{alice}. | |
13778 | ||
13779 | @item @code{listen} (default: @var{'()}) | |
13780 | Whether to listen on specific IP addresses or hostnames, defaults to | |
13781 | all. | |
13782 | ||
13783 | @item @code{port} (default: @var{#f}) | |
13784 | Whether to listen on an alternative port, which defaults to 9418. | |
13785 | ||
13786 | @item @code{whitelist} (default: @var{'()}) | |
13787 | If not empty, only allow access to this list of directories. | |
13788 | ||
13789 | @item @code{extra-options} (default: @var{'()}) | |
13790 | Extra options will be passed to @code{git daemon}, please run | |
13791 | @command{man git-daemon} for more information. | |
13792 | ||
13793 | @end table | |
13794 | @end deftp | |
13795 | ||
0ae8c15a LC |
13796 | @node Setuid Programs |
13797 | @subsection Setuid Programs | |
13798 | ||
13799 | @cindex setuid programs | |
13800 | Some programs need to run with ``root'' privileges, even when they are | |
13801 | launched by unprivileged users. A notorious example is the | |
4d40227c LC |
13802 | @command{passwd} program, which users can run to change their |
13803 | password, and which needs to access the @file{/etc/passwd} and | |
0ae8c15a LC |
13804 | @file{/etc/shadow} files---something normally restricted to root, for |
13805 | obvious security reasons. To address that, these executables are | |
13806 | @dfn{setuid-root}, meaning that they always run with root privileges | |
13807 | (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual}, | |
f7e4ae7f | 13808 | for more info about the setuid mechanism.) |
0ae8c15a LC |
13809 | |
13810 | The store itself @emph{cannot} contain setuid programs: that would be a | |
13811 | security issue since any user on the system can write derivations that | |
13812 | populate the store (@pxref{The Store}). Thus, a different mechanism is | |
13813 | used: instead of changing the setuid bit directly on files that are in | |
13814 | the store, we let the system administrator @emph{declare} which programs | |
13815 | should be setuid root. | |
13816 | ||
13817 | The @code{setuid-programs} field of an @code{operating-system} | |
13818 | declaration contains a list of G-expressions denoting the names of | |
13819 | programs to be setuid-root (@pxref{Using the Configuration System}). | |
13820 | For instance, the @command{passwd} program, which is part of the Shadow | |
13821 | package, can be designated by this G-expression (@pxref{G-Expressions}): | |
13822 | ||
13823 | @example | |
13824 | #~(string-append #$shadow "/bin/passwd") | |
13825 | @end example | |
13826 | ||
13827 | A default set of setuid programs is defined by the | |
13828 | @code{%setuid-programs} variable of the @code{(gnu system)} module. | |
13829 | ||
13830 | @defvr {Scheme Variable} %setuid-programs | |
13831 | A list of G-expressions denoting common programs that are setuid-root. | |
13832 | ||
13833 | The list includes commands such as @command{passwd}, @command{ping}, | |
13834 | @command{su}, and @command{sudo}. | |
13835 | @end defvr | |
13836 | ||
13837 | Under the hood, the actual setuid programs are created in the | |
13838 | @file{/run/setuid-programs} directory at system activation time. The | |
13839 | files in this directory refer to the ``real'' binaries, which are in the | |
13840 | store. | |
13841 | ||
efb5e833 LC |
13842 | @node X.509 Certificates |
13843 | @subsection X.509 Certificates | |
13844 | ||
13845 | @cindex HTTPS, certificates | |
13846 | @cindex X.509 certificates | |
13847 | @cindex TLS | |
13848 | Web servers available over HTTPS (that is, HTTP over the transport-layer | |
13849 | security mechanism, TLS) send client programs an @dfn{X.509 certificate} | |
13850 | that the client can then use to @emph{authenticate} the server. To do | |
13851 | that, clients verify that the server's certificate is signed by a | |
13852 | so-called @dfn{certificate authority} (CA). But to verify the CA's | |
13853 | signature, clients must have first acquired the CA's certificate. | |
13854 | ||
13855 | Web browsers such as GNU@tie{}IceCat include their own set of CA | |
13856 | certificates, such that they are able to verify CA signatures | |
13857 | out-of-the-box. | |
13858 | ||
13859 | However, most other programs that can talk HTTPS---@command{wget}, | |
13860 | @command{git}, @command{w3m}, etc.---need to be told where CA | |
13861 | certificates can be found. | |
13862 | ||
13863 | @cindex @code{nss-certs} | |
13864 | In GuixSD, this is done by adding a package that provides certificates | |
13865 | to the @code{packages} field of the @code{operating-system} declaration | |
13866 | (@pxref{operating-system Reference}). GuixSD includes one such package, | |
13867 | @code{nss-certs}, which is a set of CA certificates provided as part of | |
13868 | Mozilla's Network Security Services. | |
13869 | ||
13870 | Note that it is @emph{not} part of @var{%base-packages}, so you need to | |
13871 | explicitly add it. The @file{/etc/ssl/certs} directory, which is where | |
13872 | most applications and libraries look for certificates by default, points | |
13873 | to the certificates installed globally. | |
13874 | ||
b3129f2b LC |
13875 | Unprivileged users, including users of Guix on a foreign distro, |
13876 | can also install their own certificate package in | |
efb5e833 LC |
13877 | their profile. A number of environment variables need to be defined so |
13878 | that applications and libraries know where to find them. Namely, the | |
13879 | OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE} | |
13880 | variables. Some applications add their own environment variables; for | |
13881 | instance, the Git version control system honors the certificate bundle | |
b3129f2b LC |
13882 | pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you |
13883 | would typically run something like: | |
efb5e833 | 13884 | |
b3129f2b LC |
13885 | @example |
13886 | $ guix package -i nss-certs | |
13887 | $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs" | |
13888 | $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt" | |
13889 | $ export GIT_SSL_CAINFO="$SSL_CERT_FILE" | |
13890 | @end example | |
efb5e833 | 13891 | |
996ed739 LC |
13892 | @node Name Service Switch |
13893 | @subsection Name Service Switch | |
13894 | ||
13895 | @cindex name service switch | |
13896 | @cindex NSS | |
13897 | The @code{(gnu system nss)} module provides bindings to the | |
1068f26b | 13898 | configuration file of the libc @dfn{name service switch} or @dfn{NSS} |
996ed739 LC |
13899 | (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference |
13900 | Manual}). In a nutshell, the NSS is a mechanism that allows libc to be | |
13901 | extended with new ``name'' lookup methods for system databases, which | |
13902 | includes host names, service names, user accounts, and more (@pxref{Name | |
13903 | Service Switch, System Databases and Name Service Switch,, libc, The GNU | |
13904 | C Library Reference Manual}). | |
13905 | ||
13906 | The NSS configuration specifies, for each system database, which lookup | |
13907 | method is to be used, and how the various methods are chained | |
13908 | together---for instance, under which circumstances NSS should try the | |
13909 | next method in the list. The NSS configuration is given in the | |
13910 | @code{name-service-switch} field of @code{operating-system} declarations | |
13911 | (@pxref{operating-system Reference, @code{name-service-switch}}). | |
13912 | ||
4c9050c6 LC |
13913 | @cindex nss-mdns |
13914 | @cindex .local, host name lookup | |
996ed739 | 13915 | As an example, the declaration below configures the NSS to use the |
4c9050c6 LC |
13916 | @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns} |
13917 | back-end}, which supports host name lookups over multicast DNS (mDNS) | |
13918 | for host names ending in @code{.local}: | |
996ed739 LC |
13919 | |
13920 | @example | |
13921 | (name-service-switch | |
13922 | (hosts (list %files ;first, check /etc/hosts | |
13923 | ||
13924 | ;; If the above did not succeed, try | |
13925 | ;; with 'mdns_minimal'. | |
13926 | (name-service | |
13927 | (name "mdns_minimal") | |
13928 | ||
13929 | ;; 'mdns_minimal' is authoritative for | |
13930 | ;; '.local'. When it returns "not found", | |
13931 | ;; no need to try the next methods. | |
13932 | (reaction (lookup-specification | |
13933 | (not-found => return)))) | |
13934 | ||
13935 | ;; Then fall back to DNS. | |
13936 | (name-service | |
13937 | (name "dns")) | |
13938 | ||
13939 | ;; Finally, try with the "full" 'mdns'. | |
13940 | (name-service | |
13941 | (name "mdns"))))) | |
13942 | @end example | |
13943 | ||
1068f26b AE |
13944 | Do not worry: the @code{%mdns-host-lookup-nss} variable (see below) |
13945 | contains this configuration, so you will not have to type it if all you | |
15137a29 LC |
13946 | want is to have @code{.local} host lookup working. |
13947 | ||
4c9050c6 LC |
13948 | Note that, in this case, in addition to setting the |
13949 | @code{name-service-switch} of the @code{operating-system} declaration, | |
cc9c1f39 LC |
13950 | you also need to use @code{avahi-service} (@pxref{Networking Services, |
13951 | @code{avahi-service}}), or @var{%desktop-services}, which includes it | |
13952 | (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible | |
13953 | to the name service cache daemon (@pxref{Base Services, | |
13954 | @code{nscd-service}}). | |
15137a29 LC |
13955 | |
13956 | For convenience, the following variables provide typical NSS | |
13957 | configurations. | |
13958 | ||
13959 | @defvr {Scheme Variable} %default-nss | |
13960 | This is the default name service switch configuration, a | |
13961 | @code{name-service-switch} object. | |
13962 | @end defvr | |
13963 | ||
13964 | @defvr {Scheme Variable} %mdns-host-lookup-nss | |
13965 | This is the name service switch configuration with support for host name | |
13966 | lookup over multicast DNS (mDNS) for host names ending in @code{.local}. | |
13967 | @end defvr | |
4c9050c6 | 13968 | |
996ed739 | 13969 | The reference for name service switch configuration is given below. It |
1068f26b | 13970 | is a direct mapping of the configuration file format of the C library , so |
996ed739 LC |
13971 | please refer to the C library manual for more information (@pxref{NSS |
13972 | Configuration File,,, libc, The GNU C Library Reference Manual}). | |
1068f26b | 13973 | Compared to the configuration file format of libc NSS, it has the advantage |
996ed739 | 13974 | not only of adding this warm parenthetic feel that we like, but also |
1068f26b | 13975 | static checks: you will know about syntax errors and typos as soon as you |
996ed739 LC |
13976 | run @command{guix system}. |
13977 | ||
996ed739 LC |
13978 | @deftp {Data Type} name-service-switch |
13979 | ||
13980 | This is the data type representation the configuration of libc's name | |
13981 | service switch (NSS). Each field below represents one of the supported | |
13982 | system databases. | |
13983 | ||
13984 | @table @code | |
13985 | @item aliases | |
13986 | @itemx ethers | |
13987 | @itemx group | |
13988 | @itemx gshadow | |
13989 | @itemx hosts | |
13990 | @itemx initgroups | |
13991 | @itemx netgroup | |
13992 | @itemx networks | |
13993 | @itemx password | |
13994 | @itemx public-key | |
13995 | @itemx rpc | |
13996 | @itemx services | |
13997 | @itemx shadow | |
13998 | The system databases handled by the NSS. Each of these fields must be a | |
1068f26b | 13999 | list of @code{<name-service>} objects (see below). |
996ed739 LC |
14000 | @end table |
14001 | @end deftp | |
14002 | ||
14003 | @deftp {Data Type} name-service | |
14004 | ||
14005 | This is the data type representing an actual name service and the | |
14006 | associated lookup action. | |
14007 | ||
14008 | @table @code | |
14009 | @item name | |
14010 | A string denoting the name service (@pxref{Services in the NSS | |
14011 | configuration,,, libc, The GNU C Library Reference Manual}). | |
14012 | ||
4aee6e60 LC |
14013 | Note that name services listed here must be visible to nscd. This is |
14014 | achieved by passing the @code{#:name-services} argument to | |
14015 | @code{nscd-service} the list of packages providing the needed name | |
14016 | services (@pxref{Base Services, @code{nscd-service}}). | |
14017 | ||
996ed739 LC |
14018 | @item reaction |
14019 | An action specified using the @code{lookup-specification} macro | |
14020 | (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library | |
14021 | Reference Manual}). For example: | |
14022 | ||
14023 | @example | |
14024 | (lookup-specification (unavailable => continue) | |
14025 | (success => return)) | |
14026 | @end example | |
14027 | @end table | |
14028 | @end deftp | |
0ae8c15a | 14029 | |
fd1b1fa2 LC |
14030 | @node Initial RAM Disk |
14031 | @subsection Initial RAM Disk | |
14032 | ||
e32171ee JD |
14033 | @cindex initrd |
14034 | @cindex initial RAM disk | |
fd1b1fa2 LC |
14035 | For bootstrapping purposes, the Linux-Libre kernel is passed an |
14036 | @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary | |
1068f26b | 14037 | root file system as well as an initialization script. The latter is |
fd1b1fa2 LC |
14038 | responsible for mounting the real root file system, and for loading any |
14039 | kernel modules that may be needed to achieve that. | |
14040 | ||
14041 | The @code{initrd} field of an @code{operating-system} declaration allows | |
14042 | you to specify which initrd you would like to use. The @code{(gnu | |
47bdc5a1 MO |
14043 | system linux-initrd)} module provides three ways to build an initrd: the |
14044 | high-level @code{base-initrd} procedure and the low-level | |
14045 | @code{raw-initrd} and @code{expression->initrd} procedures. | |
fd1b1fa2 LC |
14046 | |
14047 | The @code{base-initrd} procedure is intended to cover most common uses. | |
14048 | For example, if you want to add a bunch of kernel modules to be loaded | |
14049 | at boot time, you can define the @code{initrd} field of the operating | |
14050 | system declaration like this: | |
14051 | ||
14052 | @example | |
52ac153e | 14053 | (initrd (lambda (file-systems . rest) |
027981d6 LC |
14054 | ;; Create a standard initrd that has modules "foo.ko" |
14055 | ;; and "bar.ko", as well as their dependencies, in | |
14056 | ;; addition to the modules available by default. | |
52ac153e | 14057 | (apply base-initrd file-systems |
027981d6 | 14058 | #:extra-modules '("foo" "bar") |
52ac153e | 14059 | rest))) |
fd1b1fa2 LC |
14060 | @end example |
14061 | ||
52ac153e | 14062 | The @code{base-initrd} procedure also handles common use cases that |
1068f26b AE |
14063 | involves using the system as a QEMU guest, or as a ``live'' system with |
14064 | volatile root file system. | |
fd1b1fa2 | 14065 | |
47bdc5a1 MO |
14066 | The @code{base-initrd} procedure is built from @code{raw-initrd} procedure. |
14067 | Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level, | |
14068 | such as trying to guess which kernel modules and packages should be included | |
14069 | to the initrd. An example use of @code{raw-initrd} is when a user has | |
14070 | a custom Linux kernel configuration and default kernel modules included by | |
14071 | @code{base-initrd} are not available. | |
14072 | ||
14073 | The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd} | |
14074 | honors several options passed on the Linux kernel command line | |
14075 | (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the | |
4af2fafd | 14076 | @code{-append} option of QEMU), notably: |
e90cf6c1 LC |
14077 | |
14078 | @table @code | |
14079 | @item --load=@var{boot} | |
14080 | Tell the initial RAM disk to load @var{boot}, a file containing a Scheme | |
14081 | program, once it has mounted the root file system. | |
14082 | ||
14083 | GuixSD uses this option to yield control to a boot program that runs the | |
dd17bc38 | 14084 | service activation programs and then spawns the GNU@tie{}Shepherd, the |
e90cf6c1 LC |
14085 | initialization system. |
14086 | ||
14087 | @item --root=@var{root} | |
1068f26b | 14088 | Mount @var{root} as the root file system. @var{root} can be a |
e90cf6c1 LC |
14089 | device name like @code{/dev/sda1}, a partition label, or a partition |
14090 | UUID. | |
14091 | ||
14092 | @item --system=@var{system} | |
14093 | Have @file{/run/booted-system} and @file{/run/current-system} point to | |
14094 | @var{system}. | |
14095 | ||
14096 | @item modprobe.blacklist=@var{modules}@dots{} | |
14097 | @cindex module, black-listing | |
14098 | @cindex black list, of kernel modules | |
14099 | Instruct the initial RAM disk as well as the @command{modprobe} command | |
14100 | (from the kmod package) to refuse to load @var{modules}. @var{modules} | |
14101 | must be a comma-separated list of module names---e.g., | |
14102 | @code{usbkbd,9pnet}. | |
14103 | ||
14104 | @item --repl | |
14105 | Start a read-eval-print loop (REPL) from the initial RAM disk before it | |
14106 | tries to load kernel modules and to mount the root file system. Our | |
14107 | marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will | |
14108 | love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference | |
14109 | Manual}, for more information on Guile's REPL. | |
14110 | ||
14111 | @end table | |
14112 | ||
14113 | Now that you know all the features that initial RAM disks produced by | |
47bdc5a1 MO |
14114 | @code{base-initrd} and @code{raw-initrd} provide, |
14115 | here is how to use it and customize it further. | |
e90cf6c1 | 14116 | |
e32171ee JD |
14117 | @cindex initrd |
14118 | @cindex initial RAM disk | |
47bdc5a1 MO |
14119 | @deffn {Monadic Procedure} raw-initrd @var{file-systems} @ |
14120 | [#:linux-modules '()] [#:mapped-devices '()] @ | |
14121 | [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f] | |
14122 | Return a monadic derivation that builds a raw initrd. @var{file-systems} is | |
1068f26b | 14123 | a list of file systems to be mounted by the initrd, possibly in addition to |
fd1b1fa2 | 14124 | the root file system specified on the kernel command line via @code{--root}. |
47bdc5a1 | 14125 | @var{linux-modules} is a list of kernel modules to be loaded at boot time. |
52ac153e LC |
14126 | @var{mapped-devices} is a list of device mappings to realize before |
14127 | @var{file-systems} are mounted (@pxref{Mapped Devices}). | |
47bdc5a1 MO |
14128 | @var{helper-packages} is a list of packages to be copied in the initrd. It may |
14129 | include @code{e2fsck/static} or other packages needed by the initrd to check | |
14130 | root partition. | |
fd1b1fa2 LC |
14131 | |
14132 | When @var{qemu-networking?} is true, set up networking with the standard QEMU | |
1068f26b AE |
14133 | parameters. When @var{virtio?} is true, load additional modules so that the |
14134 | initrd can be used as a QEMU guest with para-virtualized I/O drivers. | |
fd1b1fa2 LC |
14135 | |
14136 | When @var{volatile-root?} is true, the root file system is writable but any changes | |
14137 | to it are lost. | |
47bdc5a1 MO |
14138 | @end deffn |
14139 | ||
14140 | @deffn {Monadic Procedure} base-initrd @var{file-systems} @ | |
14141 | [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@ | |
14142 | [#:virtio? #t] [#:extra-modules '()] | |
14143 | Return a monadic derivation that builds a generic initrd. @var{file-systems} is | |
14144 | a list of file systems to be mounted by the initrd like for @code{raw-initrd}. | |
14145 | @var{mapped-devices}, @var{qemu-networking?} and @var{volatile-root?} | |
14146 | also behaves as in @code{raw-initrd}. | |
14147 | ||
14148 | When @var{virtio?} is true, load additional modules so that the | |
14149 | initrd can be used as a QEMU guest with para-virtualized I/O drivers. | |
fd1b1fa2 LC |
14150 | |
14151 | The initrd is automatically populated with all the kernel modules necessary | |
14152 | for @var{file-systems} and for the given options. However, additional kernel | |
14153 | modules can be listed in @var{extra-modules}. They will be added to the initrd, and | |
14154 | loaded at boot time in the order in which they appear. | |
14155 | @end deffn | |
14156 | ||
14157 | Needless to say, the initrds we produce and use embed a | |
14158 | statically-linked Guile, and the initialization program is a Guile | |
14159 | program. That gives a lot of flexibility. The | |
14160 | @code{expression->initrd} procedure builds such an initrd, given the | |
14161 | program to run in that initrd. | |
14162 | ||
14163 | @deffn {Monadic Procedure} expression->initrd @var{exp} @ | |
4ee96a79 | 14164 | [#:guile %guile-static-stripped] [#:name "guile-initrd"] |
fd1b1fa2 LC |
14165 | Return a derivation that builds a Linux initrd (a gzipped cpio archive) |
14166 | containing @var{guile} and that evaluates @var{exp}, a G-expression, | |
df650fa8 LC |
14167 | upon booting. All the derivations referenced by @var{exp} are |
14168 | automatically copied to the initrd. | |
fd1b1fa2 LC |
14169 | @end deffn |
14170 | ||
88faf933 LC |
14171 | @node GRUB Configuration |
14172 | @subsection GRUB Configuration | |
14173 | ||
14174 | @cindex GRUB | |
14175 | @cindex boot loader | |
14176 | ||
14177 | The operating system uses GNU@tie{}GRUB as its boot loader | |
14178 | (@pxref{Overview, overview of GRUB,, grub, GNU GRUB Manual}). It is | |
1068f26b AE |
14179 | configured using a @code{grub-configuration} declaration. This data type |
14180 | is exported by the @code{(gnu system grub)} module and described below. | |
88faf933 LC |
14181 | |
14182 | @deftp {Data Type} grub-configuration | |
14183 | The type of a GRUB configuration declaration. | |
14184 | ||
14185 | @table @asis | |
14186 | ||
14187 | @item @code{device} | |
14188 | This is a string denoting the boot device. It must be a device name | |
14189 | understood by the @command{grub-install} command, such as | |
14190 | @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub, | |
14191 | GNU GRUB Manual}). | |
14192 | ||
14193 | @item @code{menu-entries} (default: @code{()}) | |
14194 | A possibly empty list of @code{menu-entry} objects (see below), denoting | |
14195 | entries to appear in the GRUB boot menu, in addition to the current | |
14196 | system entry and the entry pointing to previous system generations. | |
14197 | ||
14198 | @item @code{default-entry} (default: @code{0}) | |
1068f26b AE |
14199 | The index of the default boot menu entry. Index 0 is for the entry of the |
14200 | current system. | |
88faf933 LC |
14201 | |
14202 | @item @code{timeout} (default: @code{5}) | |
14203 | The number of seconds to wait for keyboard input before booting. Set to | |
14204 | 0 to boot immediately, and to -1 to wait indefinitely. | |
14205 | ||
14206 | @item @code{theme} (default: @var{%default-theme}) | |
14207 | The @code{grub-theme} object describing the theme to use. | |
9b06f503 LC |
14208 | |
14209 | @item @code{grub} (default: @code{grub}) | |
14210 | The GRUB package to use. | |
88faf933 LC |
14211 | @end table |
14212 | ||
14213 | @end deftp | |
14214 | ||
44d5f54e LC |
14215 | @cindex dual boot |
14216 | @cindex boot menu | |
88faf933 LC |
14217 | Should you want to list additional boot menu entries @i{via} the |
14218 | @code{menu-entries} field above, you will need to create them with the | |
44d5f54e LC |
14219 | @code{menu-entry} form. For example, imagine you want to be able to |
14220 | boot another distro (hard to imagine!), you can define a menu entry | |
14221 | along these lines: | |
14222 | ||
14223 | @example | |
14224 | (menu-entry | |
14225 | (label "The Other Distro") | |
14226 | (linux "/boot/old/vmlinux-2.6.32") | |
14227 | (linux-arguments '("root=/dev/sda2")) | |
14228 | (initrd "/boot/old/initrd")) | |
14229 | @end example | |
14230 | ||
14231 | Details below. | |
88faf933 LC |
14232 | |
14233 | @deftp {Data Type} menu-entry | |
14234 | The type of an entry in the GRUB boot menu. | |
14235 | ||
14236 | @table @asis | |
14237 | ||
14238 | @item @code{label} | |
35ed9306 | 14239 | The label to show in the menu---e.g., @code{"GNU"}. |
88faf933 LC |
14240 | |
14241 | @item @code{linux} | |
44d5f54e LC |
14242 | The Linux kernel image to boot, for example: |
14243 | ||
14244 | @example | |
14245 | (file-append linux-libre "/bzImage") | |
14246 | @end example | |
88faf933 | 14247 | |
1ef8b72a CM |
14248 | It is also possible to specify a device explicitly in the file path |
14249 | using GRUB's device naming convention (@pxref{Naming convention,,, grub, | |
14250 | GNU GRUB manual}), for example: | |
14251 | ||
14252 | @example | |
14253 | "(hd0,msdos1)/boot/vmlinuz" | |
14254 | @end example | |
14255 | ||
14256 | If the device is specified explicitly as above, then the @code{device} | |
14257 | field is ignored entirely. | |
14258 | ||
88faf933 LC |
14259 | @item @code{linux-arguments} (default: @code{()}) |
14260 | The list of extra Linux kernel command-line arguments---e.g., | |
14261 | @code{("console=ttyS0")}. | |
14262 | ||
14263 | @item @code{initrd} | |
14264 | A G-Expression or string denoting the file name of the initial RAM disk | |
14265 | to use (@pxref{G-Expressions}). | |
14266 | ||
1ef8b72a CM |
14267 | @item @code{device} (default: @code{#f}) |
14268 | The device where the kernel and initrd are to be found---i.e., the GRUB | |
14269 | @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}). | |
14270 | ||
14271 | This may be a file system label (a string), a file system UUID (a | |
14272 | bytevector, @pxref{File Systems}), or @code{#f}, in which case GRUB will | |
14273 | search the device containing the file specified by the @code{linux} | |
14274 | field (@pxref{search,,, grub, GNU GRUB manual}). It must @emph{not} be | |
14275 | an OS device name such as @file{/dev/sda1}. | |
14276 | ||
14277 | @item @code{device-mount-point} (default: @code{"/"}) | |
14278 | The mount point of the above device on the system. You probably do not | |
14279 | need to change the default value. GuixSD uses it to strip the prefix of | |
14280 | store file names for systems where @file{/gnu} or @file{/gnu/store} is | |
14281 | on a separate partition. | |
14282 | ||
88faf933 LC |
14283 | @end table |
14284 | @end deftp | |
14285 | ||
14286 | @c FIXME: Write documentation once it's stable. | |
14287 | Themes are created using the @code{grub-theme} form, which is not | |
14288 | documented yet. | |
14289 | ||
14290 | @defvr {Scheme Variable} %default-theme | |
14291 | This is the default GRUB theme used by the operating system, with a | |
14292 | fancy background image displaying the GNU and Guix logos. | |
14293 | @end defvr | |
14294 | ||
14295 | ||
cf4a9129 LC |
14296 | @node Invoking guix system |
14297 | @subsection Invoking @code{guix system} | |
0918e64a | 14298 | |
1068f26b | 14299 | Once you have written an operating system declaration as seen in the |
cf4a9129 LC |
14300 | previous section, it can be @dfn{instantiated} using the @command{guix |
14301 | system} command. The synopsis is: | |
4af2447e | 14302 | |
cf4a9129 LC |
14303 | @example |
14304 | guix system @var{options}@dots{} @var{action} @var{file} | |
14305 | @end example | |
4af2447e | 14306 | |
cf4a9129 LC |
14307 | @var{file} must be the name of a file containing an |
14308 | @code{operating-system} declaration. @var{action} specifies how the | |
a40424bd | 14309 | operating system is instantiated. Currently the following values are |
cf4a9129 | 14310 | supported: |
4af2447e | 14311 | |
cf4a9129 LC |
14312 | @table @code |
14313 | @item reconfigure | |
14314 | Build the operating system described in @var{file}, activate it, and | |
8074b330 CM |
14315 | switch to it@footnote{This action (and the related actions |
14316 | @code{switch-generation} and @code{roll-back}) are usable only on | |
14317 | systems already running GuixSD.}. | |
4af2447e | 14318 | |
cf4a9129 LC |
14319 | This effects all the configuration specified in @var{file}: user |
14320 | accounts, system services, global package list, setuid programs, etc. | |
240b57f0 LC |
14321 | The command starts system services specified in @var{file} that are not |
14322 | currently running; if a service is currently running, it does not | |
1068f26b | 14323 | attempt to upgrade it since this would not be possible without stopping it |
240b57f0 | 14324 | first. |
4af2447e | 14325 | |
067a2e2d CM |
14326 | This command creates a new generation whose number is one greater than |
14327 | the current generation (as reported by @command{guix system | |
14328 | list-generations}). If that generation already exists, it will be | |
14329 | overwritten. This behavior mirrors that of @command{guix package} | |
14330 | (@pxref{Invoking guix package}). | |
14331 | ||
cf4a9129 LC |
14332 | It also adds a GRUB menu entry for the new OS configuration, and moves |
14333 | entries for older configurations to a submenu---unless | |
14334 | @option{--no-grub} is passed. | |
4af2447e | 14335 | |
240b57f0 | 14336 | @quotation Note |
bf2479c7 LC |
14337 | @c The paragraph below refers to the problem discussed at |
14338 | @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>. | |
14339 | It is highly recommended to run @command{guix pull} once before you run | |
14340 | @command{guix system reconfigure} for the first time (@pxref{Invoking | |
14341 | guix pull}). Failing to do that you would see an older version of Guix | |
14342 | once @command{reconfigure} has completed. | |
240b57f0 | 14343 | @end quotation |
bf2479c7 | 14344 | |
8074b330 | 14345 | @item switch-generation |
e32171ee | 14346 | @cindex generations |
8074b330 CM |
14347 | Switch to an existing system generation. This action atomically |
14348 | switches the system profile to the specified system generation. It also | |
14349 | rearranges the system's existing GRUB menu entries. It makes the menu | |
14350 | entry for the specified system generation the default, and it moves the | |
14351 | entries for the other generations to a submenu. The next time the | |
14352 | system boots, it will use the specified system generation. | |
14353 | ||
14354 | The target generation can be specified explicitly by its generation | |
14355 | number. For example, the following invocation would switch to system | |
14356 | generation 7: | |
14357 | ||
14358 | @example | |
14359 | guix system switch-generation 7 | |
14360 | @end example | |
14361 | ||
14362 | The target generation can also be specified relative to the current | |
14363 | generation with the form @code{+N} or @code{-N}, where @code{+3} means | |
14364 | ``3 generations ahead of the current generation,'' and @code{-1} means | |
14365 | ``1 generation prior to the current generation.'' When specifying a | |
14366 | negative value such as @code{-1}, you must precede it with @code{--} to | |
14367 | prevent it from being parsed as an option. For example: | |
14368 | ||
14369 | @example | |
14370 | guix system switch-generation -- -1 | |
14371 | @end example | |
14372 | ||
14373 | Currently, the effect of invoking this action is @emph{only} to switch | |
14374 | the system profile to an existing generation and rearrange the GRUB menu | |
14375 | entries. To actually start using the target system generation, you must | |
14376 | reboot after running this action. In the future, it will be updated to | |
14377 | do the same things as @command{reconfigure}, like activating and | |
14378 | deactivating services. | |
14379 | ||
14380 | This action will fail if the specified generation does not exist. | |
14381 | ||
14382 | @item roll-back | |
e32171ee | 14383 | @cindex rolling back |
8074b330 CM |
14384 | Switch to the preceding system generation. The next time the system |
14385 | boots, it will use the preceding system generation. This is the inverse | |
14386 | of @command{reconfigure}, and it is exactly the same as invoking | |
14387 | @command{switch-generation} with an argument of @code{-1}. | |
14388 | ||
14389 | Currently, as with @command{switch-generation}, you must reboot after | |
14390 | running this action to actually start using the preceding system | |
14391 | generation. | |
14392 | ||
cf4a9129 | 14393 | @item build |
1068f26b | 14394 | Build the derivation of the operating system, which includes all the |
cf4a9129 LC |
14395 | configuration files and programs needed to boot and run the system. |
14396 | This action does not actually install anything. | |
113daf62 | 14397 | |
cf4a9129 LC |
14398 | @item init |
14399 | Populate the given directory with all the files necessary to run the | |
14400 | operating system specified in @var{file}. This is useful for first-time | |
4705641f | 14401 | installations of GuixSD. For instance: |
113daf62 LC |
14402 | |
14403 | @example | |
cf4a9129 | 14404 | guix system init my-os-config.scm /mnt |
113daf62 LC |
14405 | @end example |
14406 | ||
cf4a9129 LC |
14407 | copies to @file{/mnt} all the store items required by the configuration |
14408 | specified in @file{my-os-config.scm}. This includes configuration | |
14409 | files, packages, and so on. It also creates other essential files | |
14410 | needed for the system to operate correctly---e.g., the @file{/etc}, | |
14411 | @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file. | |
113daf62 | 14412 | |
cf4a9129 LC |
14413 | This command also installs GRUB on the device specified in |
14414 | @file{my-os-config}, unless the @option{--no-grub} option was passed. | |
113daf62 | 14415 | |
cf4a9129 LC |
14416 | @item vm |
14417 | @cindex virtual machine | |
0276f697 | 14418 | @cindex VM |
f535dcbe | 14419 | @anchor{guix system vm} |
1068f26b | 14420 | Build a virtual machine that contains the operating system declared in |
cf4a9129 | 14421 | @var{file}, and return a script to run that virtual machine (VM). |
1068f26b | 14422 | Arguments given to the script are passed to QEMU. |
113daf62 | 14423 | |
cf4a9129 | 14424 | The VM shares its store with the host system. |
113daf62 | 14425 | |
0276f697 LC |
14426 | Additional file systems can be shared between the host and the VM using |
14427 | the @code{--share} and @code{--expose} command-line options: the former | |
14428 | specifies a directory to be shared with write access, while the latter | |
14429 | provides read-only access to the shared directory. | |
14430 | ||
14431 | The example below creates a VM in which the user's home directory is | |
14432 | accessible read-only, and where the @file{/exchange} directory is a | |
1068f26b | 14433 | read-write mapping of @file{$HOME/tmp} on the host: |
0276f697 LC |
14434 | |
14435 | @example | |
14436 | guix system vm my-config.scm \ | |
14437 | --expose=$HOME --share=$HOME/tmp=/exchange | |
14438 | @end example | |
14439 | ||
6aa260af LC |
14440 | On GNU/Linux, the default is to boot directly to the kernel; this has |
14441 | the advantage of requiring only a very tiny root disk image since the | |
1068f26b | 14442 | store of the host can then be mounted. |
6aa260af LC |
14443 | |
14444 | The @code{--full-boot} option forces a complete boot sequence, starting | |
14445 | with the bootloader. This requires more disk space since a root image | |
14446 | containing at least the kernel, initrd, and bootloader data files must | |
14447 | be created. The @code{--image-size} option can be used to specify the | |
1068f26b | 14448 | size of the image. |
ab11f0be | 14449 | |
cf4a9129 LC |
14450 | @item vm-image |
14451 | @itemx disk-image | |
14452 | Return a virtual machine or disk image of the operating system declared | |
14453 | in @var{file} that stands alone. Use the @option{--image-size} option | |
14454 | to specify the size of the image. | |
113daf62 | 14455 | |
cf4a9129 | 14456 | When using @code{vm-image}, the returned image is in qcow2 format, which |
97d76250 LF |
14457 | the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM}, |
14458 | for more information on how to run the image in a virtual machine. | |
113daf62 | 14459 | |
cf4a9129 LC |
14460 | When using @code{disk-image}, a raw disk image is produced; it can be |
14461 | copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is | |
1068f26b | 14462 | the device corresponding to a USB stick, one can copy the image to it |
cf4a9129 | 14463 | using the following command: |
113daf62 | 14464 | |
cf4a9129 LC |
14465 | @example |
14466 | # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc | |
14467 | @end example | |
113daf62 | 14468 | |
1c8a81b1 DT |
14469 | @item container |
14470 | Return a script to run the operating system declared in @var{file} | |
14471 | within a container. Containers are a set of lightweight isolation | |
14472 | mechanisms provided by the kernel Linux-libre. Containers are | |
14473 | substantially less resource-demanding than full virtual machines since | |
14474 | the kernel, shared objects, and other resources can be shared with the | |
14475 | host system; this also means they provide thinner isolation. | |
14476 | ||
14477 | Currently, the script must be run as root in order to support more than | |
14478 | a single user and group. The container shares its store with the host | |
14479 | system. | |
14480 | ||
14481 | As with the @code{vm} action (@pxref{guix system vm}), additional file | |
14482 | systems to be shared between the host and container can be specified | |
14483 | using the @option{--share} and @option{--expose} options: | |
14484 | ||
14485 | @example | |
14486 | guix system container my-config.scm \ | |
14487 | --expose=$HOME --share=$HOME/tmp=/exchange | |
14488 | @end example | |
14489 | ||
0f252e26 | 14490 | @quotation Note |
cfd35b4e | 14491 | This option requires Linux-libre 3.19 or newer. |
0f252e26 DT |
14492 | @end quotation |
14493 | ||
cf4a9129 | 14494 | @end table |
113daf62 | 14495 | |
ccd7158d LC |
14496 | @var{options} can contain any of the common build options (@pxref{Common |
14497 | Build Options}). In addition, @var{options} can contain one of the | |
14498 | following: | |
113daf62 | 14499 | |
cf4a9129 LC |
14500 | @table @option |
14501 | @item --system=@var{system} | |
14502 | @itemx -s @var{system} | |
1068f26b | 14503 | Attempt to build for @var{system} instead of the host system type. |
cf4a9129 | 14504 | This works as per @command{guix build} (@pxref{Invoking guix build}). |
113daf62 | 14505 | |
f3f427c2 LC |
14506 | @item --derivation |
14507 | @itemx -d | |
14508 | Return the derivation file name of the given operating system without | |
14509 | building anything. | |
14510 | ||
cf4a9129 LC |
14511 | @item --image-size=@var{size} |
14512 | For the @code{vm-image} and @code{disk-image} actions, create an image | |
14513 | of the given @var{size}. @var{size} may be a number of bytes, or it may | |
4a44d7bb LC |
14514 | include a unit as a suffix (@pxref{Block size, size specifications,, |
14515 | coreutils, GNU Coreutils}). | |
db030303 LC |
14516 | |
14517 | @item --on-error=@var{strategy} | |
14518 | Apply @var{strategy} when an error occurs when reading @var{file}. | |
14519 | @var{strategy} may be one of the following: | |
14520 | ||
14521 | @table @code | |
14522 | @item nothing-special | |
14523 | Report the error concisely and exit. This is the default strategy. | |
14524 | ||
14525 | @item backtrace | |
14526 | Likewise, but also display a backtrace. | |
14527 | ||
14528 | @item debug | |
14529 | Report the error and enter Guile's debugger. From there, you can run | |
14530 | commands such as @code{,bt} to get a backtrace, @code{,locals} to | |
1068f26b AE |
14531 | display local variable values, and more generally inspect the state of the |
14532 | program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for | |
db030303 LC |
14533 | a list of available debugging commands. |
14534 | @end table | |
113daf62 | 14535 | @end table |
113daf62 | 14536 | |
eca69fc0 LC |
14537 | @quotation Note |
14538 | All the actions above, except @code{build} and @code{init}, | |
14539 | can use KVM support in the Linux-libre kernel. Specifically, if the | |
14540 | machine has hardware virtualization support, the corresponding | |
cf4a9129 | 14541 | KVM kernel module should be loaded, and the @file{/dev/kvm} device node |
1068f26b | 14542 | must exist and be readable and writable by the user and by the |
eca69fc0 LC |
14543 | build users of the daemon (@pxref{Build Environment Setup}). |
14544 | @end quotation | |
8451a568 | 14545 | |
65797bff LC |
14546 | Once you have built, configured, re-configured, and re-re-configured |
14547 | your GuixSD installation, you may find it useful to list the operating | |
14548 | system generations available on disk---and that you can choose from the | |
14549 | GRUB boot menu: | |
14550 | ||
14551 | @table @code | |
14552 | ||
14553 | @item list-generations | |
14554 | List a summary of each generation of the operating system available on | |
14555 | disk, in a human-readable way. This is similar to the | |
14556 | @option{--list-generations} option of @command{guix package} | |
14557 | (@pxref{Invoking guix package}). | |
14558 | ||
14559 | Optionally, one can specify a pattern, with the same syntax that is used | |
14560 | in @command{guix package --list-generations}, to restrict the list of | |
14561 | generations displayed. For instance, the following command displays | |
1068f26b | 14562 | generations that are up to 10 days old: |
65797bff LC |
14563 | |
14564 | @example | |
14565 | $ guix system list-generations 10d | |
14566 | @end example | |
14567 | ||
14568 | @end table | |
14569 | ||
d6c3267a LC |
14570 | The @command{guix system} command has even more to offer! The following |
14571 | sub-commands allow you to visualize how your system services relate to | |
14572 | each other: | |
14573 | ||
14574 | @anchor{system-extension-graph} | |
14575 | @table @code | |
14576 | ||
14577 | @item extension-graph | |
14578 | Emit in Dot/Graphviz format to standard output the @dfn{service | |
14579 | extension graph} of the operating system defined in @var{file} | |
14580 | (@pxref{Service Composition}, for more information on service | |
14581 | extensions.) | |
14582 | ||
14583 | The command: | |
14584 | ||
14585 | @example | |
14586 | $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf | |
14587 | @end example | |
14588 | ||
14589 | produces a PDF file showing the extension relations among services. | |
14590 | ||
710fa231 AK |
14591 | @anchor{system-shepherd-graph} |
14592 | @item shepherd-graph | |
6f305ea5 | 14593 | Emit in Dot/Graphviz format to standard output the @dfn{dependency |
dd17bc38 AK |
14594 | graph} of shepherd services of the operating system defined in |
14595 | @var{file}. @xref{Shepherd Services}, for more information and for an | |
14596 | example graph. | |
6f305ea5 | 14597 | |
d6c3267a LC |
14598 | @end table |
14599 | ||
97d76250 | 14600 | @node Running GuixSD in a VM |
70ac09a5 | 14601 | @subsection Running GuixSD in a Virtual Machine |
97d76250 | 14602 | |
e32171ee | 14603 | @cindex virtual machine |
97d76250 LF |
14604 | One way to run GuixSD in a virtual machine (VM) is to build a GuixSD |
14605 | virtual machine image using @command{guix system vm-image} | |
14606 | (@pxref{Invoking guix system}). The returned image is in qcow2 format, | |
14607 | which the @uref{http://qemu.org/, QEMU emulator} can efficiently use. | |
14608 | ||
e32171ee | 14609 | @cindex QEMU |
97d76250 LF |
14610 | To run the image in QEMU, copy it out of the store (@pxref{The Store}) |
14611 | and give yourself permission to write to the copy. When invoking QEMU, | |
14612 | you must choose a system emulator that is suitable for your hardware | |
14613 | platform. Here is a minimal QEMU invocation that will boot the result | |
14614 | of @command{guix system vm-image} on x86_64 hardware: | |
14615 | ||
14616 | @example | |
14617 | $ qemu-system-x86_64 \ | |
14618 | -net user -net nic,model=virtio \ | |
14619 | -enable-kvm -m 256 /tmp/qemu-image | |
14620 | @end example | |
14621 | ||
14622 | Here is what each of these options means: | |
14623 | ||
14624 | @table @code | |
14625 | @item qemu-system-x86_64 | |
14626 | This specifies the hardware platform to emulate. This should match the | |
14627 | host. | |
14628 | ||
14629 | @item -net user | |
14630 | Enable the unprivileged user-mode network stack. The guest OS can | |
14631 | access the host but not vice versa. This is the simplest way to get the | |
58806e6f | 14632 | guest OS online. |
97d76250 LF |
14633 | |
14634 | @item -net nic,model=virtio | |
1068f26b | 14635 | You must create a network interface of a given model. If you do not |
97d76250 LF |
14636 | create a NIC, the boot will fail. Assuming your hardware platform is |
14637 | x86_64, you can get a list of available NIC models by running | |
14638 | @command{qemu-system-x86_64 -net nic,model=help}. | |
14639 | ||
14640 | @item -enable-kvm | |
14641 | If your system has hardware virtualization extensions, enabling the | |
1068f26b | 14642 | virtual machine support (KVM) of the Linux kernel will make things run |
97d76250 LF |
14643 | faster. |
14644 | ||
14645 | @item -m 256 | |
14646 | RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB, | |
7414de0a | 14647 | which may be insufficient for some operations. |
97d76250 LF |
14648 | |
14649 | @item /tmp/qemu-image | |
14650 | The file name of the qcow2 image. | |
14651 | @end table | |
d6c3267a | 14652 | |
3ddc50db DC |
14653 | The default @command{run-vm.sh} script that is returned by an invokation of |
14654 | @command{guix system vm} does not add a @command{-net user} flag by default. | |
14655 | To get network access from within the vm add the @code{(dhcp-client-service)} | |
14656 | to your system definition and start the VM using | |
14657 | @command{`guix system vm config.scm` -net user}. An important caveat of using | |
14658 | @command{-net user} for networking is that @command{ping} will not work, because | |
14659 | it uses the ICMP protocol. You'll have to use a different command to check for | |
14660 | network connectivity, like for example @command{curl}. | |
14661 | ||
14662 | @subsubsection Connecting Through SSH | |
14663 | ||
e32171ee JD |
14664 | @cindex SSH |
14665 | @cindex SSH server | |
3ddc50db DC |
14666 | To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)} |
14667 | or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently | |
14668 | boot unsupervised. It requires you to type some characters to initialize the | |
14669 | randomness generator. In addition you need to forward the SSH port, 22 by | |
14670 | default, to the host. You can do this with | |
14671 | ||
14672 | @example | |
14673 | `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22 | |
14674 | @end example | |
14675 | ||
14676 | To connect to the VM you can run | |
14677 | ||
14678 | @example | |
14679 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 | |
14680 | @end example | |
14681 | ||
14682 | The @command{-p} tells @command{ssh} the port you want to connect to. | |
14683 | @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining | |
14684 | every time you modify your @command{config.scm} file and the | |
14685 | @command{-o StrictHostKeyChecking=no} prevents you from having to allow a | |
14686 | connection to an unknown host every time you connect. | |
14687 | ||
14688 | @subsubsection Using @command{virt-viewer} with Spice | |
14689 | ||
14690 | As an alternative to the default @command{qemu} graphical client you can | |
14691 | use the @command{remote-viewer} from the @command{virt-viewer} package. To | |
14692 | connect pass the @command{-spice port=5930,disable-ticketing} flag to | |
14693 | @command{qemu}. See previous section for further information on how to do this. | |
14694 | ||
14695 | Spice also allows you to do some nice stuff like share your clipboard with your | |
14696 | VM. To enable that you'll also have to pass the following flags to @command{qemu}: | |
14697 | ||
14698 | @example | |
14699 | -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5 | |
14700 | -chardev spicevmc,name=vdagent,id=vdagent | |
14701 | -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent, | |
14702 | name=com.redhat.spice.0 | |
14703 | @end example | |
14704 | ||
14705 | You'll also need to add the @pxref{Miscellaneous Services, Spice service}. | |
14706 | ||
cf4a9129 LC |
14707 | @node Defining Services |
14708 | @subsection Defining Services | |
8451a568 | 14709 | |
eb524192 | 14710 | The previous sections show the available services and how one can combine |
0adfe95a LC |
14711 | them in an @code{operating-system} declaration. But how do we define |
14712 | them in the first place? And what is a service anyway? | |
8451a568 | 14713 | |
0adfe95a LC |
14714 | @menu |
14715 | * Service Composition:: The model for composing services. | |
14716 | * Service Types and Services:: Types and services. | |
14717 | * Service Reference:: API reference. | |
dd17bc38 | 14718 | * Shepherd Services:: A particular type of service. |
0adfe95a LC |
14719 | @end menu |
14720 | ||
14721 | @node Service Composition | |
14722 | @subsubsection Service Composition | |
14723 | ||
14724 | @cindex services | |
14725 | @cindex daemons | |
14726 | Here we define a @dfn{service} as, broadly, something that extends the | |
1068f26b | 14727 | functionality of the operating system. Often a service is a process---a |
0adfe95a LC |
14728 | @dfn{daemon}---started when the system boots: a secure shell server, a |
14729 | Web server, the Guix build daemon, etc. Sometimes a service is a daemon | |
14730 | whose execution can be triggered by another daemon---e.g., an FTP server | |
14731 | started by @command{inetd} or a D-Bus service activated by | |
14732 | @command{dbus-daemon}. Occasionally, a service does not map to a | |
14733 | daemon. For instance, the ``account'' service collects user accounts | |
14734 | and makes sure they exist when the system runs; the ``udev'' service | |
14735 | collects device management rules and makes them available to the eudev | |
1068f26b AE |
14736 | daemon; the @file{/etc} service populates the @file{/etc} directory |
14737 | of the system. | |
0adfe95a | 14738 | |
d6c3267a | 14739 | @cindex service extensions |
0adfe95a | 14740 | GuixSD services are connected by @dfn{extensions}. For instance, the |
1068f26b | 14741 | secure shell service @emph{extends} the Shepherd---the GuixSD |
dd17bc38 AK |
14742 | initialization system, running as PID@tie{}1---by giving it the command |
14743 | lines to start and stop the secure shell daemon (@pxref{Networking | |
14744 | Services, @code{lsh-service}}); the UPower service extends the D-Bus | |
14745 | service by passing it its @file{.service} specification, and extends the | |
14746 | udev service by passing it device management rules (@pxref{Desktop | |
14747 | Services, @code{upower-service}}); the Guix daemon service extends the | |
14748 | Shepherd by passing it the command lines to start and stop the daemon, | |
14749 | and extends the account service by passing it a list of required build | |
14750 | user accounts (@pxref{Base Services}). | |
0adfe95a LC |
14751 | |
14752 | All in all, services and their ``extends'' relations form a directed | |
14753 | acyclic graph (DAG). If we represent services as boxes and extensions | |
14754 | as arrows, a typical system might provide something like this: | |
14755 | ||
14756 | @image{images/service-graph,,5in,Typical service extension graph.} | |
14757 | ||
d62e201c LC |
14758 | @cindex system service |
14759 | At the bottom, we see the @dfn{system service}, which produces the | |
14760 | directory containing everything to run and boot the system, as returned | |
14761 | by the @command{guix system build} command. @xref{Service Reference}, | |
14762 | to learn about the other service types shown here. | |
d6c3267a LC |
14763 | @xref{system-extension-graph, the @command{guix system extension-graph} |
14764 | command}, for information on how to generate this representation for a | |
14765 | particular operating system definition. | |
0adfe95a LC |
14766 | |
14767 | @cindex service types | |
14768 | Technically, developers can define @dfn{service types} to express these | |
14769 | relations. There can be any number of services of a given type on the | |
14770 | system---for instance, a system running two instances of the GNU secure | |
14771 | shell server (lsh) has two instances of @var{lsh-service-type}, with | |
14772 | different parameters. | |
14773 | ||
14774 | The following section describes the programming interface for service | |
14775 | types and services. | |
14776 | ||
14777 | @node Service Types and Services | |
14778 | @subsubsection Service Types and Services | |
14779 | ||
14780 | A @dfn{service type} is a node in the DAG described above. Let us start | |
14781 | with a simple example, the service type for the Guix build daemon | |
14782 | (@pxref{Invoking guix-daemon}): | |
14783 | ||
14784 | @example | |
14785 | (define guix-service-type | |
14786 | (service-type | |
14787 | (name 'guix) | |
14788 | (extensions | |
d4053c71 | 14789 | (list (service-extension shepherd-root-service-type guix-shepherd-service) |
0adfe95a LC |
14790 | (service-extension account-service-type guix-accounts) |
14791 | (service-extension activation-service-type guix-activation))))) | |
14792 | @end example | |
8451a568 | 14793 | |
cf4a9129 | 14794 | @noindent |
1068f26b | 14795 | It defines two things: |
0adfe95a LC |
14796 | |
14797 | @enumerate | |
14798 | @item | |
14799 | A name, whose sole purpose is to make inspection and debugging easier. | |
14800 | ||
14801 | @item | |
14802 | A list of @dfn{service extensions}, where each extension designates the | |
1068f26b AE |
14803 | target service type and a procedure that, given the parameters of the |
14804 | service, returns a list of objects to extend the service of that type. | |
0adfe95a LC |
14805 | |
14806 | Every service type has at least one service extension. The only | |
14807 | exception is the @dfn{boot service type}, which is the ultimate service. | |
14808 | @end enumerate | |
14809 | ||
14810 | In this example, @var{guix-service-type} extends three services: | |
14811 | ||
14812 | @table @var | |
d4053c71 AK |
14813 | @item shepherd-root-service-type |
14814 | The @var{guix-shepherd-service} procedure defines how the Shepherd | |
14815 | service is extended. Namely, it returns a @code{<shepherd-service>} | |
14816 | object that defines how @command{guix-daemon} is started and stopped | |
14817 | (@pxref{Shepherd Services}). | |
0adfe95a LC |
14818 | |
14819 | @item account-service-type | |
14820 | This extension for this service is computed by @var{guix-accounts}, | |
14821 | which returns a list of @code{user-group} and @code{user-account} | |
14822 | objects representing the build user accounts (@pxref{Invoking | |
14823 | guix-daemon}). | |
14824 | ||
14825 | @item activation-service-type | |
14826 | Here @var{guix-activation} is a procedure that returns a gexp, which is | |
14827 | a code snippet to run at ``activation time''---e.g., when the service is | |
14828 | booted. | |
14829 | @end table | |
14830 | ||
14831 | A service of this type is instantiated like this: | |
14832 | ||
14833 | @example | |
14834 | (service guix-service-type | |
14835 | (guix-configuration | |
14836 | (build-accounts 5) | |
14837 | (use-substitutes? #f))) | |
14838 | @end example | |
14839 | ||
14840 | The second argument to the @code{service} form is a value representing | |
14841 | the parameters of this specific service instance. | |
14842 | @xref{guix-configuration-type, @code{guix-configuration}}, for | |
14843 | information about the @code{guix-configuration} data type. | |
14844 | ||
14845 | @var{guix-service-type} is quite simple because it extends other | |
14846 | services but is not extensible itself. | |
14847 | ||
14848 | @c @subsubsubsection Extensible Service Types | |
14849 | ||
14850 | The service type for an @emph{extensible} service looks like this: | |
14851 | ||
14852 | @example | |
14853 | (define udev-service-type | |
14854 | (service-type (name 'udev) | |
14855 | (extensions | |
d4053c71 AK |
14856 | (list (service-extension shepherd-root-service-type |
14857 | udev-shepherd-service))) | |
0adfe95a LC |
14858 | |
14859 | (compose concatenate) ;concatenate the list of rules | |
14860 | (extend (lambda (config rules) | |
14861 | (match config | |
14862 | (($ <udev-configuration> udev initial-rules) | |
14863 | (udev-configuration | |
14864 | (udev udev) ;the udev package to use | |
14865 | (rules (append initial-rules rules))))))))) | |
14866 | @end example | |
14867 | ||
14868 | This is the service type for the | |
14869 | @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device | |
14870 | management daemon}. Compared to the previous example, in addition to an | |
d4053c71 | 14871 | extension of @var{shepherd-root-service-type}, we see two new fields: |
0adfe95a LC |
14872 | |
14873 | @table @code | |
14874 | @item compose | |
14875 | This is the procedure to @dfn{compose} the list of extensions to | |
14876 | services of this type. | |
14877 | ||
14878 | Services can extend the udev service by passing it lists of rules; we | |
14879 | compose those extensions simply by concatenating them. | |
14880 | ||
14881 | @item extend | |
1068f26b | 14882 | This procedure defines how the value of the service is @dfn{extended} with |
0adfe95a LC |
14883 | the composition of the extensions. |
14884 | ||
14885 | Udev extensions are composed into a list of rules, but the udev service | |
14886 | value is itself a @code{<udev-configuration>} record. So here, we | |
a40424bd | 14887 | extend that record by appending the list of rules it contains to the |
0adfe95a LC |
14888 | list of contributed rules. |
14889 | @end table | |
14890 | ||
14891 | There can be only one instance of an extensible service type such as | |
14892 | @var{udev-service-type}. If there were more, the | |
14893 | @code{service-extension} specifications would be ambiguous. | |
14894 | ||
14895 | Still here? The next section provides a reference of the programming | |
14896 | interface for services. | |
14897 | ||
14898 | @node Service Reference | |
14899 | @subsubsection Service Reference | |
14900 | ||
14901 | We have seen an overview of service types (@pxref{Service Types and | |
14902 | Services}). This section provides a reference on how to manipulate | |
14903 | services and service types. This interface is provided by the | |
14904 | @code{(gnu services)} module. | |
14905 | ||
14906 | @deffn {Scheme Procedure} service @var{type} @var{value} | |
14907 | Return a new service of @var{type}, a @code{<service-type>} object (see | |
14908 | below.) @var{value} can be any object; it represents the parameters of | |
14909 | this particular service instance. | |
14910 | @end deffn | |
14911 | ||
14912 | @deffn {Scheme Procedure} service? @var{obj} | |
14913 | Return true if @var{obj} is a service. | |
14914 | @end deffn | |
8451a568 | 14915 | |
0adfe95a LC |
14916 | @deffn {Scheme Procedure} service-kind @var{service} |
14917 | Return the type of @var{service}---i.e., a @code{<service-type>} object. | |
14918 | @end deffn | |
14919 | ||
14920 | @deffn {Scheme Procedure} service-parameters @var{service} | |
14921 | Return the value associated with @var{service}. It represents its | |
14922 | parameters. | |
14923 | @end deffn | |
14924 | ||
14925 | Here is an example of how a service is created and manipulated: | |
14926 | ||
14927 | @example | |
14928 | (define s | |
14929 | (service nginx-service-type | |
14930 | (nginx-configuration | |
14931 | (nginx nginx) | |
14932 | (log-directory log-directory) | |
14933 | (run-directory run-directory) | |
14934 | (file config-file)))) | |
14935 | ||
14936 | (service? s) | |
14937 | @result{} #t | |
14938 | ||
14939 | (eq? (service-kind s) nginx-service-type) | |
14940 | @result{} #t | |
14941 | @end example | |
14942 | ||
cd6f6c22 LC |
14943 | The @code{modify-services} form provides a handy way to change the |
14944 | parameters of some of the services of a list such as | |
4d343a14 | 14945 | @var{%base-services} (@pxref{Base Services, @code{%base-services}}). It |
7414de0a | 14946 | evaluates to a list of services. Of course, you could always use |
4d343a14 CM |
14947 | standard list combinators such as @code{map} and @code{fold} to do that |
14948 | (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual}); | |
14949 | @code{modify-services} simply provides a more concise form for this | |
14950 | common pattern. | |
cd6f6c22 LC |
14951 | |
14952 | @deffn {Scheme Syntax} modify-services @var{services} @ | |
14953 | (@var{type} @var{variable} => @var{body}) @dots{} | |
14954 | ||
14955 | Modify the services listed in @var{services} according to the given | |
14956 | clauses. Each clause has the form: | |
14957 | ||
14958 | @example | |
14959 | (@var{type} @var{variable} => @var{body}) | |
14960 | @end example | |
14961 | ||
4d343a14 CM |
14962 | where @var{type} is a service type---e.g., |
14963 | @code{guix-service-type}---and @var{variable} is an identifier that is | |
14964 | bound within the @var{body} to the service parameters---e.g., a | |
14965 | @code{guix-configuration} instance---of the original service of that | |
14966 | @var{type}. | |
cd6f6c22 | 14967 | |
4d343a14 CM |
14968 | The @var{body} should evaluate to the new service parameters, which will |
14969 | be used to configure the new service. This new service will replace the | |
14970 | original in the resulting list. Because a service's service parameters | |
7414de0a | 14971 | are created using @code{define-record-type*}, you can write a succinct |
4d343a14 CM |
14972 | @var{body} that evaluates to the new service parameters by using the |
14973 | @code{inherit} feature that @code{define-record-type*} provides. | |
14974 | ||
b53daad0 | 14975 | @xref{Using the Configuration System}, for example usage. |
cd6f6c22 | 14976 | |
cd6f6c22 LC |
14977 | @end deffn |
14978 | ||
14979 | Next comes the programming interface for service types. This is | |
14980 | something you want to know when writing new service definitions, but not | |
14981 | necessarily when simply looking for ways to customize your | |
14982 | @code{operating-system} declaration. | |
14983 | ||
0adfe95a LC |
14984 | @deftp {Data Type} service-type |
14985 | @cindex service type | |
14986 | This is the representation of a @dfn{service type} (@pxref{Service Types | |
14987 | and Services}). | |
14988 | ||
14989 | @table @asis | |
14990 | @item @code{name} | |
14991 | This is a symbol, used only to simplify inspection and debugging. | |
14992 | ||
14993 | @item @code{extensions} | |
1068f26b | 14994 | A non-empty list of @code{<service-extension>} objects (see below). |
0adfe95a LC |
14995 | |
14996 | @item @code{compose} (default: @code{#f}) | |
14997 | If this is @code{#f}, then the service type denotes services that cannot | |
14998 | be extended---i.e., services that do not receive ``values'' from other | |
14999 | services. | |
15000 | ||
15001 | Otherwise, it must be a one-argument procedure. The procedure is called | |
15002 | by @code{fold-services} and is passed a list of values collected from | |
15003 | extensions. It must return a value that is a valid parameter value for | |
15004 | the service instance. | |
15005 | ||
15006 | @item @code{extend} (default: @code{#f}) | |
15007 | If this is @code{#f}, services of this type cannot be extended. | |
15008 | ||
15009 | Otherwise, it must be a two-argument procedure: @code{fold-services} | |
1068f26b | 15010 | calls it, passing it the initial value of the service as the first argument |
0adfe95a LC |
15011 | and the result of applying @code{compose} to the extension values as the |
15012 | second argument. | |
15013 | @end table | |
15014 | ||
15015 | @xref{Service Types and Services}, for examples. | |
15016 | @end deftp | |
15017 | ||
15018 | @deffn {Scheme Procedure} service-extension @var{target-type} @ | |
15019 | @var{compute} | |
15020 | Return a new extension for services of type @var{target-type}. | |
15021 | @var{compute} must be a one-argument procedure: @code{fold-services} | |
15022 | calls it, passing it the value associated with the service that provides | |
15023 | the extension; it must return a valid value for the target service. | |
15024 | @end deffn | |
15025 | ||
15026 | @deffn {Scheme Procedure} service-extension? @var{obj} | |
15027 | Return true if @var{obj} is a service extension. | |
15028 | @end deffn | |
15029 | ||
71654dfd LC |
15030 | Occasionally, you might want to simply extend an existing service. This |
15031 | involves creating a new service type and specifying the extension of | |
15032 | interest, which can be verbose; the @code{simple-service} procedure | |
15033 | provides a shorthand for this. | |
15034 | ||
15035 | @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value} | |
15036 | Return a service that extends @var{target} with @var{value}. This works | |
15037 | by creating a singleton service type @var{name}, of which the returned | |
15038 | service is an instance. | |
15039 | ||
15040 | For example, this extends mcron (@pxref{Scheduled Job Execution}) with | |
15041 | an additional job: | |
15042 | ||
15043 | @example | |
15044 | (simple-service 'my-mcron-job mcron-service-type | |
15045 | #~(job '(next-hour (3)) "guix gc -F 2G")) | |
15046 | @end example | |
15047 | @end deffn | |
15048 | ||
0adfe95a LC |
15049 | At the core of the service abstraction lies the @code{fold-services} |
15050 | procedure, which is responsible for ``compiling'' a list of services | |
d62e201c LC |
15051 | down to a single directory that contains everything needed to boot and |
15052 | run the system---the directory shown by the @command{guix system build} | |
15053 | command (@pxref{Invoking guix system}). In essence, it propagates | |
15054 | service extensions down the service graph, updating each node parameters | |
15055 | on the way, until it reaches the root node. | |
0adfe95a LC |
15056 | |
15057 | @deffn {Scheme Procedure} fold-services @var{services} @ | |
d62e201c | 15058 | [#:target-type @var{system-service-type}] |
0adfe95a LC |
15059 | Fold @var{services} by propagating their extensions down to the root of |
15060 | type @var{target-type}; return the root service adjusted accordingly. | |
15061 | @end deffn | |
15062 | ||
15063 | Lastly, the @code{(gnu services)} module also defines several essential | |
15064 | service types, some of which are listed below. | |
15065 | ||
d62e201c LC |
15066 | @defvr {Scheme Variable} system-service-type |
15067 | This is the root of the service graph. It produces the system directory | |
15068 | as returned by the @command{guix system build} command. | |
15069 | @end defvr | |
15070 | ||
0adfe95a | 15071 | @defvr {Scheme Variable} boot-service-type |
d62e201c LC |
15072 | The type of the ``boot service'', which produces the @dfn{boot script}. |
15073 | The boot script is what the initial RAM disk runs when booting. | |
0adfe95a LC |
15074 | @end defvr |
15075 | ||
15076 | @defvr {Scheme Variable} etc-service-type | |
15077 | The type of the @file{/etc} service. This service can be extended by | |
15078 | passing it name/file tuples such as: | |
15079 | ||
15080 | @example | |
15081 | (list `("issue" ,(plain-file "issue" "Welcome!\n"))) | |
15082 | @end example | |
15083 | ||
15084 | In this example, the effect would be to add an @file{/etc/issue} file | |
15085 | pointing to the given file. | |
15086 | @end defvr | |
15087 | ||
15088 | @defvr {Scheme Variable} setuid-program-service-type | |
15089 | Type for the ``setuid-program service''. This service collects lists of | |
15090 | executable file names, passed as gexps, and adds them to the set of | |
15091 | setuid-root programs on the system (@pxref{Setuid Programs}). | |
15092 | @end defvr | |
15093 | ||
af4c3fd5 LC |
15094 | @defvr {Scheme Variable} profile-service-type |
15095 | Type of the service that populates the @dfn{system profile}---i.e., the | |
15096 | programs under @file{/run/current-system/profile}. Other services can | |
15097 | extend it by passing it lists of packages to add to the system profile. | |
15098 | @end defvr | |
15099 | ||
0adfe95a | 15100 | |
dd17bc38 AK |
15101 | @node Shepherd Services |
15102 | @subsubsection Shepherd Services | |
0adfe95a | 15103 | |
e32171ee | 15104 | @cindex shepherd services |
0adfe95a LC |
15105 | @cindex PID 1 |
15106 | @cindex init system | |
a40424bd CM |
15107 | The @code{(gnu services shepherd)} module provides a way to define |
15108 | services managed by the GNU@tie{}Shepherd, which is the GuixSD | |
15109 | initialization system---the first process that is started when the | |
1068f26b AE |
15110 | system boots, also known as PID@tie{}1 |
15111 | (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}). | |
6f305ea5 | 15112 | |
dd17bc38 AK |
15113 | Services in the Shepherd can depend on each other. For instance, the |
15114 | SSH daemon may need to be started after the syslog daemon has been | |
15115 | started, which in turn can only happen once all the file systems have | |
15116 | been mounted. The simple operating system defined earlier (@pxref{Using | |
15117 | the Configuration System}) results in a service graph like this: | |
6f305ea5 | 15118 | |
710fa231 | 15119 | @image{images/shepherd-graph,,5in,Typical shepherd service graph.} |
6f305ea5 LC |
15120 | |
15121 | You can actually generate such a graph for any operating system | |
710fa231 AK |
15122 | definition using the @command{guix system shepherd-graph} command |
15123 | (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}). | |
6f305ea5 | 15124 | |
d4053c71 AK |
15125 | The @var{%shepherd-root-service} is a service object representing |
15126 | PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended | |
15127 | by passing it lists of @code{<shepherd-service>} objects. | |
0adfe95a | 15128 | |
d4053c71 | 15129 | @deftp {Data Type} shepherd-service |
dd17bc38 | 15130 | The data type representing a service managed by the Shepherd. |
0adfe95a LC |
15131 | |
15132 | @table @asis | |
15133 | @item @code{provision} | |
15134 | This is a list of symbols denoting what the service provides. | |
15135 | ||
dd17bc38 AK |
15136 | These are the names that may be passed to @command{herd start}, |
15137 | @command{herd status}, and similar commands (@pxref{Invoking herd,,, | |
15138 | shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the | |
15139 | @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details. | |
0adfe95a LC |
15140 | |
15141 | @item @code{requirements} (default: @code{'()}) | |
dd17bc38 | 15142 | List of symbols denoting the Shepherd services this one depends on. |
0adfe95a LC |
15143 | |
15144 | @item @code{respawn?} (default: @code{#t}) | |
15145 | Whether to restart the service when it stops, for instance when the | |
15146 | underlying process dies. | |
15147 | ||
15148 | @item @code{start} | |
15149 | @itemx @code{stop} (default: @code{#~(const #f)}) | |
dd17bc38 AK |
15150 | The @code{start} and @code{stop} fields refer to the Shepherd's |
15151 | facilities to start and stop processes (@pxref{Service De- and | |
15152 | Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as | |
15153 | G-expressions that get expanded in the Shepherd configuration file | |
15154 | (@pxref{G-Expressions}). | |
0adfe95a LC |
15155 | |
15156 | @item @code{documentation} | |
15157 | A documentation string, as shown when running: | |
15158 | ||
15159 | @example | |
dd17bc38 | 15160 | herd doc @var{service-name} |
0adfe95a LC |
15161 | @end example |
15162 | ||
15163 | where @var{service-name} is one of the symbols in @var{provision} | |
dd17bc38 | 15164 | (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}). |
fae685b9 LC |
15165 | |
15166 | @item @code{modules} (default: @var{%default-modules}) | |
15167 | This is the list of modules that must be in scope when @code{start} and | |
15168 | @code{stop} are evaluated. | |
15169 | ||
0adfe95a LC |
15170 | @end table |
15171 | @end deftp | |
15172 | ||
d4053c71 | 15173 | @defvr {Scheme Variable} shepherd-root-service-type |
dd17bc38 | 15174 | The service type for the Shepherd ``root service''---i.e., PID@tie{}1. |
0adfe95a LC |
15175 | |
15176 | This is the service type that extensions target when they want to create | |
dd17bc38 | 15177 | shepherd services (@pxref{Service Types and Services}, for an example). |
d4053c71 | 15178 | Each extension must pass a list of @code{<shepherd-service>}. |
0adfe95a LC |
15179 | @end defvr |
15180 | ||
d4053c71 | 15181 | @defvr {Scheme Variable} %shepherd-root-service |
0adfe95a LC |
15182 | This service represents PID@tie{}1. |
15183 | @end defvr | |
8451a568 | 15184 | |
8451a568 | 15185 | |
cf4a9129 LC |
15186 | @node Installing Debugging Files |
15187 | @section Installing Debugging Files | |
8451a568 | 15188 | |
cf4a9129 LC |
15189 | @cindex debugging files |
15190 | Program binaries, as produced by the GCC compilers for instance, are | |
15191 | typically written in the ELF format, with a section containing | |
15192 | @dfn{debugging information}. Debugging information is what allows the | |
15193 | debugger, GDB, to map binary code to source code; it is required to | |
15194 | debug a compiled program in good conditions. | |
8451a568 | 15195 | |
cf4a9129 LC |
15196 | The problem with debugging information is that is takes up a fair amount |
15197 | of disk space. For example, debugging information for the GNU C Library | |
15198 | weighs in at more than 60 MiB. Thus, as a user, keeping all the | |
15199 | debugging info of all the installed programs is usually not an option. | |
15200 | Yet, space savings should not come at the cost of an impediment to | |
15201 | debugging---especially in the GNU system, which should make it easier | |
15202 | for users to exert their computing freedom (@pxref{GNU Distribution}). | |
8451a568 | 15203 | |
cf4a9129 LC |
15204 | Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a |
15205 | mechanism that allows users to get the best of both worlds: debugging | |
15206 | information can be stripped from the binaries and stored in separate | |
15207 | files. GDB is then able to load debugging information from those files, | |
15208 | when they are available (@pxref{Separate Debug Files,,, gdb, Debugging | |
15209 | with GDB}). | |
8451a568 | 15210 | |
cf4a9129 LC |
15211 | The GNU distribution takes advantage of this by storing debugging |
15212 | information in the @code{lib/debug} sub-directory of a separate package | |
15213 | output unimaginatively called @code{debug} (@pxref{Packages with | |
15214 | Multiple Outputs}). Users can choose to install the @code{debug} output | |
15215 | of a package when they need it. For instance, the following command | |
15216 | installs the debugging information for the GNU C Library and for GNU | |
15217 | Guile: | |
8451a568 LC |
15218 | |
15219 | @example | |
cf4a9129 | 15220 | guix package -i glibc:debug guile:debug |
8451a568 LC |
15221 | @end example |
15222 | ||
cf4a9129 LC |
15223 | GDB must then be told to look for debug files in the user's profile, by |
15224 | setting the @code{debug-file-directory} variable (consider setting it | |
15225 | from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with | |
15226 | GDB}): | |
8451a568 | 15227 | |
cf4a9129 LC |
15228 | @example |
15229 | (gdb) set debug-file-directory ~/.guix-profile/lib/debug | |
15230 | @end example | |
8451a568 | 15231 | |
cf4a9129 LC |
15232 | From there on, GDB will pick up debugging information from the |
15233 | @code{.debug} files under @file{~/.guix-profile/lib/debug}. | |
8451a568 | 15234 | |
cf4a9129 LC |
15235 | In addition, you will most likely want GDB to be able to show the source |
15236 | code being debugged. To do that, you will have to unpack the source | |
15237 | code of the package of interest (obtained with @code{guix build | |
15238 | --source}, @pxref{Invoking guix build}), and to point GDB to that source | |
15239 | directory using the @code{directory} command (@pxref{Source Path, | |
15240 | @code{directory},, gdb, Debugging with GDB}). | |
8451a568 | 15241 | |
cf4a9129 LC |
15242 | @c XXX: keep me up-to-date |
15243 | The @code{debug} output mechanism in Guix is implemented by the | |
15244 | @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is | |
1068f26b AE |
15245 | opt-in---debugging information is available only for the packages |
15246 | with definitions explicitly declaring a @code{debug} output. This may be | |
15247 | changed to opt-out in the future if our build farm servers can handle | |
cf4a9129 LC |
15248 | the load. To check whether a package has a @code{debug} output, use |
15249 | @command{guix package --list-available} (@pxref{Invoking guix package}). | |
8451a568 | 15250 | |
8451a568 | 15251 | |
05962f29 LC |
15252 | @node Security Updates |
15253 | @section Security Updates | |
15254 | ||
09866b39 LC |
15255 | @cindex security updates |
15256 | @cindex security vulnerabilities | |
15257 | Occasionally, important security vulnerabilities are discovered in software | |
15258 | packages and must be patched. Guix developers try hard to keep track of | |
15259 | known vulnerabilities and to apply fixes as soon as possible in the | |
15260 | @code{master} branch of Guix (we do not yet provide a ``stable'' branch | |
15261 | containing only security updates.) The @command{guix lint} tool helps | |
15262 | developers find out about vulnerable versions of software packages in the | |
15263 | distribution: | |
15264 | ||
15265 | @smallexample | |
15266 | $ guix lint -c cve | |
15267 | gnu/packages/base.scm:652:2: glibc-2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547 | |
15268 | gnu/packages/gcc.scm:334:2: gcc-4.9.3: probably vulnerable to CVE-2015-5276 | |
15269 | gnu/packages/image.scm:312:2: openjpeg-2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924 | |
15270 | @dots{} | |
15271 | @end smallexample | |
15272 | ||
15273 | @xref{Invoking guix lint}, for more information. | |
15274 | ||
843858b8 | 15275 | @quotation Note |
09866b39 LC |
15276 | As of version @value{VERSION}, the feature described below is considered |
15277 | ``beta''. | |
843858b8 | 15278 | @end quotation |
05962f29 | 15279 | |
09866b39 | 15280 | Guix follows a functional |
05962f29 LC |
15281 | package management discipline (@pxref{Introduction}), which implies |
15282 | that, when a package is changed, @emph{every package that depends on it} | |
15283 | must be rebuilt. This can significantly slow down the deployment of | |
15284 | fixes in core packages such as libc or Bash, since basically the whole | |
15285 | distribution would need to be rebuilt. Using pre-built binaries helps | |
15286 | (@pxref{Substitutes}), but deployment may still take more time than | |
15287 | desired. | |
15288 | ||
15289 | @cindex grafts | |
1068f26b | 15290 | To address this, Guix implements @dfn{grafts}, a mechanism that allows |
05962f29 LC |
15291 | for fast deployment of critical updates without the costs associated |
15292 | with a whole-distribution rebuild. The idea is to rebuild only the | |
15293 | package that needs to be patched, and then to ``graft'' it onto packages | |
15294 | explicitly installed by the user and that were previously referring to | |
15295 | the original package. The cost of grafting is typically very low, and | |
15296 | order of magnitudes lower than a full rebuild of the dependency chain. | |
15297 | ||
15298 | @cindex replacements of packages, for grafts | |
15299 | For instance, suppose a security update needs to be applied to Bash. | |
15300 | Guix developers will provide a package definition for the ``fixed'' | |
15301 | Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining | |
15302 | Packages}). Then, the original package definition is augmented with a | |
15303 | @code{replacement} field pointing to the package containing the bug fix: | |
15304 | ||
15305 | @example | |
15306 | (define bash | |
15307 | (package | |
15308 | (name "bash") | |
15309 | ;; @dots{} | |
15310 | (replacement bash-fixed))) | |
15311 | @end example | |
15312 | ||
c22a1324 LC |
15313 | From there on, any package depending directly or indirectly on Bash---as |
15314 | reported by @command{guix gc --requisites} (@pxref{Invoking guix | |
15315 | gc})---that is installed is automatically ``rewritten'' to refer to | |
05962f29 | 15316 | @var{bash-fixed} instead of @var{bash}. This grafting process takes |
1068f26b | 15317 | time proportional to the size of the package, usually less than a |
c22a1324 LC |
15318 | minute for an ``average'' package on a recent machine. Grafting is |
15319 | recursive: when an indirect dependency requires grafting, then grafting | |
15320 | ``propagates'' up to the package that the user is installing. | |
05962f29 | 15321 | |
57bdd79e LC |
15322 | Currently, the length of the name and version of the graft and that of |
15323 | the package it replaces (@var{bash-fixed} and @var{bash} in the example | |
15324 | above) must be equal. This restriction mostly comes from the fact that | |
15325 | grafting works by patching files, including binary files, directly. | |
05962f29 LC |
15326 | Other restrictions may apply: for instance, when adding a graft to a |
15327 | package providing a shared library, the original shared library and its | |
15328 | replacement must have the same @code{SONAME} and be binary-compatible. | |
15329 | ||
59a4dd50 LC |
15330 | The @option{--no-grafts} command-line option allows you to forcefully |
15331 | avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}). | |
15332 | Thus, the command: | |
15333 | ||
15334 | @example | |
15335 | guix build bash --no-grafts | |
15336 | @end example | |
15337 | ||
15338 | @noindent | |
15339 | returns the store file name of the original Bash, whereas: | |
15340 | ||
15341 | @example | |
15342 | guix build bash | |
15343 | @end example | |
15344 | ||
15345 | @noindent | |
15346 | returns the store file name of the ``fixed'', replacement Bash. This | |
15347 | allows you to distinguish between the two variants of Bash. | |
15348 | ||
15349 | To verify which Bash your whole profile refers to, you can run | |
15350 | (@pxref{Invoking guix gc}): | |
15351 | ||
15352 | @example | |
15353 | guix gc -R `readlink -f ~/.guix-profile` | grep bash | |
15354 | @end example | |
15355 | ||
15356 | @noindent | |
15357 | @dots{} and compare the store file names that you get with those above. | |
15358 | Likewise for a complete GuixSD system generation: | |
15359 | ||
15360 | @example | |
15361 | guix gc -R `guix system build my-config.scm` | grep bash | |
15362 | @end example | |
15363 | ||
15364 | Lastly, to check which Bash running processes are using, you can use the | |
15365 | @command{lsof} command: | |
15366 | ||
15367 | @example | |
15368 | lsof | grep /gnu/store/.*bash | |
15369 | @end example | |
15370 | ||
05962f29 | 15371 | |
cf4a9129 LC |
15372 | @node Package Modules |
15373 | @section Package Modules | |
8451a568 | 15374 | |
cf4a9129 LC |
15375 | From a programming viewpoint, the package definitions of the |
15376 | GNU distribution are provided by Guile modules in the @code{(gnu packages | |
15377 | @dots{})} name space@footnote{Note that packages under the @code{(gnu | |
15378 | packages @dots{})} module name space are not necessarily ``GNU | |
15379 | packages''. This module naming scheme follows the usual Guile module | |
15380 | naming convention: @code{gnu} means that these modules are distributed | |
15381 | as part of the GNU system, and @code{packages} identifies modules that | |
15382 | define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile | |
15383 | Reference Manual}). For instance, the @code{(gnu packages emacs)} | |
15384 | module exports a variable named @code{emacs}, which is bound to a | |
15385 | @code{<package>} object (@pxref{Defining Packages}). | |
113daf62 | 15386 | |
300868ba | 15387 | The @code{(gnu packages @dots{})} module name space is |
cf4a9129 LC |
15388 | automatically scanned for packages by the command-line tools. For |
15389 | instance, when running @code{guix package -i emacs}, all the @code{(gnu | |
15390 | packages @dots{})} modules are scanned until one that exports a package | |
15391 | object whose name is @code{emacs} is found. This package search | |
15392 | facility is implemented in the @code{(gnu packages)} module. | |
113daf62 | 15393 | |
300868ba | 15394 | @cindex customization, of packages |
8689901f | 15395 | @cindex package module search path |
cf4a9129 | 15396 | Users can store package definitions in modules with different |
60142854 | 15397 | names---e.g., @code{(my-packages emacs)}@footnote{Note that the file |
c95ded7e LC |
15398 | name and module name must match. For instance, the @code{(my-packages |
15399 | emacs)} module must be stored in a @file{my-packages/emacs.scm} file | |
15400 | relative to the load path specified with @option{--load-path} or | |
15401 | @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,, | |
15402 | guile, GNU Guile Reference Manual}, for details.}. These package definitions | |
1068f26b AE |
15403 | will not be visible by default. Users can invoke commands such as |
15404 | @command{guix package} and @command{guix build} with the | |
c95ded7e LC |
15405 | @code{-e} option so that they know where to find the package. Better |
15406 | yet, they can use the | |
300868ba | 15407 | @code{-L} option of these commands to make those modules visible |
8689901f LC |
15408 | (@pxref{Invoking guix build, @code{--load-path}}), or define the |
15409 | @code{GUIX_PACKAGE_PATH} environment variable. This environment | |
15410 | variable makes it easy to extend or customize the distribution and is | |
15411 | honored by all the user interfaces. | |
15412 | ||
15413 | @defvr {Environment Variable} GUIX_PACKAGE_PATH | |
1068f26b AE |
15414 | This is a colon-separated list of directories to search for additional |
15415 | package modules. Directories listed in this variable take precedence | |
15416 | over the own modules of the distribution. | |
8689901f | 15417 | @end defvr |
ef5dd60a | 15418 | |
cf4a9129 LC |
15419 | The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}: |
15420 | each package is built based solely on other packages in the | |
15421 | distribution. The root of this dependency graph is a small set of | |
15422 | @dfn{bootstrap binaries}, provided by the @code{(gnu packages | |
15423 | bootstrap)} module. For more information on bootstrapping, | |
081145cf | 15424 | @pxref{Bootstrapping}. |
ef5dd60a | 15425 | |
cf4a9129 LC |
15426 | @node Packaging Guidelines |
15427 | @section Packaging Guidelines | |
ef5dd60a | 15428 | |
e32171ee | 15429 | @cindex packages, creating |
cf4a9129 LC |
15430 | The GNU distribution is nascent and may well lack some of your favorite |
15431 | packages. This section describes how you can help make the distribution | |
15432 | grow. @xref{Contributing}, for additional information on how you can | |
15433 | help. | |
ef5dd60a | 15434 | |
cf4a9129 LC |
15435 | Free software packages are usually distributed in the form of |
15436 | @dfn{source code tarballs}---typically @file{tar.gz} files that contain | |
15437 | all the source files. Adding a package to the distribution means | |
15438 | essentially two things: adding a @dfn{recipe} that describes how to | |
15439 | build the package, including a list of other packages required to build | |
f97c9175 | 15440 | it, and adding @dfn{package metadata} along with that recipe, such as a |
cf4a9129 | 15441 | description and licensing information. |
ef5dd60a | 15442 | |
cf4a9129 LC |
15443 | In Guix all this information is embodied in @dfn{package definitions}. |
15444 | Package definitions provide a high-level view of the package. They are | |
15445 | written using the syntax of the Scheme programming language; in fact, | |
15446 | for each package we define a variable bound to the package definition, | |
15447 | and export that variable from a module (@pxref{Package Modules}). | |
15448 | However, in-depth Scheme knowledge is @emph{not} a prerequisite for | |
15449 | creating packages. For more information on package definitions, | |
081145cf | 15450 | @pxref{Defining Packages}. |
ef5dd60a | 15451 | |
cf4a9129 LC |
15452 | Once a package definition is in place, stored in a file in the Guix |
15453 | source tree, it can be tested using the @command{guix build} command | |
15454 | (@pxref{Invoking guix build}). For example, assuming the new package is | |
c71979f4 LC |
15455 | called @code{gnew}, you may run this command from the Guix build tree |
15456 | (@pxref{Running Guix Before It Is Installed}): | |
ef5dd60a LC |
15457 | |
15458 | @example | |
cf4a9129 | 15459 | ./pre-inst-env guix build gnew --keep-failed |
ef5dd60a | 15460 | @end example |
ef5dd60a | 15461 | |
cf4a9129 LC |
15462 | Using @code{--keep-failed} makes it easier to debug build failures since |
15463 | it provides access to the failed build tree. Another useful | |
15464 | command-line option when debugging is @code{--log-file}, to access the | |
15465 | build log. | |
ef5dd60a | 15466 | |
cf4a9129 LC |
15467 | If the package is unknown to the @command{guix} command, it may be that |
15468 | the source file contains a syntax error, or lacks a @code{define-public} | |
15469 | clause to export the package variable. To figure it out, you may load | |
15470 | the module from Guile to get more information about the actual error: | |
ef5dd60a | 15471 | |
cf4a9129 LC |
15472 | @example |
15473 | ./pre-inst-env guile -c '(use-modules (gnu packages gnew))' | |
15474 | @end example | |
ef5dd60a | 15475 | |
cf4a9129 LC |
15476 | Once your package builds correctly, please send us a patch |
15477 | (@pxref{Contributing}). Well, if you need help, we will be happy to | |
15478 | help you too. Once the patch is committed in the Guix repository, the | |
15479 | new package automatically gets built on the supported platforms by | |
2b1cee21 | 15480 | @url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration |
cf4a9129 | 15481 | system}. |
ef5dd60a | 15482 | |
cf4a9129 LC |
15483 | @cindex substituter |
15484 | Users can obtain the new package definition simply by running | |
15485 | @command{guix pull} (@pxref{Invoking guix pull}). When | |
15486 | @code{hydra.gnu.org} is done building the package, installing the | |
15487 | package automatically downloads binaries from there | |
15488 | (@pxref{Substitutes}). The only place where human intervention is | |
15489 | needed is to review and apply the patch. | |
ef5dd60a | 15490 | |
ef5dd60a | 15491 | |
cf4a9129 | 15492 | @menu |
ec0339cd LC |
15493 | * Software Freedom:: What may go into the distribution. |
15494 | * Package Naming:: What's in a name? | |
15495 | * Version Numbers:: When the name is not enough. | |
cbd02397 | 15496 | * Synopses and Descriptions:: Helping users find the right package. |
ec0339cd LC |
15497 | * Python Modules:: Taming the snake. |
15498 | * Perl Modules:: Little pearls. | |
e1c963bf | 15499 | * Java Packages:: Coffee break. |
ec0339cd | 15500 | * Fonts:: Fond of fonts. |
cf4a9129 | 15501 | @end menu |
ef5dd60a | 15502 | |
cf4a9129 LC |
15503 | @node Software Freedom |
15504 | @subsection Software Freedom | |
ef5dd60a | 15505 | |
cf4a9129 | 15506 | @c Adapted from http://www.gnu.org/philosophy/philosophy.html. |
e32171ee | 15507 | @cindex free software |
cf4a9129 LC |
15508 | The GNU operating system has been developed so that users can have |
15509 | freedom in their computing. GNU is @dfn{free software}, meaning that | |
15510 | users have the @url{http://www.gnu.org/philosophy/free-sw.html,four | |
15511 | essential freedoms}: to run the program, to study and change the program | |
15512 | in source code form, to redistribute exact copies, and to distribute | |
15513 | modified versions. Packages found in the GNU distribution provide only | |
15514 | software that conveys these four freedoms. | |
c11a6eb1 | 15515 | |
cf4a9129 LC |
15516 | In addition, the GNU distribution follow the |
15517 | @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free | |
15518 | software distribution guidelines}. Among other things, these guidelines | |
15519 | reject non-free firmware, recommendations of non-free software, and | |
15520 | discuss ways to deal with trademarks and patents. | |
ef5dd60a | 15521 | |
1068f26b AE |
15522 | Some otherwise free upstream package sources contain a small and optional |
15523 | subset that violates the above guidelines, for instance because this subset | |
15524 | is itself non-free code. When that happens, the offending items are removed | |
15525 | with appropriate patches or code snippets in the @code{origin} form of the | |
15526 | package (@pxref{Defining Packages}). This way, @code{guix | |
cf4a9129 LC |
15527 | build --source} returns the ``freed'' source rather than the unmodified |
15528 | upstream source. | |
ef5dd60a | 15529 | |
ef5dd60a | 15530 | |
cf4a9129 LC |
15531 | @node Package Naming |
15532 | @subsection Package Naming | |
ef5dd60a | 15533 | |
e32171ee | 15534 | @cindex package name |
cf4a9129 LC |
15535 | A package has actually two names associated with it: |
15536 | First, there is the name of the @emph{Scheme variable}, the one following | |
15537 | @code{define-public}. By this name, the package can be made known in the | |
15538 | Scheme code, for instance as input to another package. Second, there is | |
15539 | the string in the @code{name} field of a package definition. This name | |
15540 | is used by package management commands such as | |
15541 | @command{guix package} and @command{guix build}. | |
ef5dd60a | 15542 | |
cf4a9129 LC |
15543 | Both are usually the same and correspond to the lowercase conversion of |
15544 | the project name chosen upstream, with underscores replaced with | |
15545 | hyphens. For instance, GNUnet is available as @code{gnunet}, and | |
15546 | SDL_net as @code{sdl-net}. | |
927097ef | 15547 | |
cf4a9129 | 15548 | We do not add @code{lib} prefixes for library packages, unless these are |
081145cf | 15549 | already part of the official project name. But @pxref{Python |
cf4a9129 LC |
15550 | Modules} and @ref{Perl Modules} for special rules concerning modules for |
15551 | the Python and Perl languages. | |
927097ef | 15552 | |
1b366ee4 | 15553 | Font package names are handled differently, @pxref{Fonts}. |
7fec52b7 | 15554 | |
ef5dd60a | 15555 | |
cf4a9129 LC |
15556 | @node Version Numbers |
15557 | @subsection Version Numbers | |
ef5dd60a | 15558 | |
e32171ee | 15559 | @cindex package version |
cf4a9129 LC |
15560 | We usually package only the latest version of a given free software |
15561 | project. But sometimes, for instance for incompatible library versions, | |
15562 | two (or more) versions of the same package are needed. These require | |
15563 | different Scheme variable names. We use the name as defined | |
15564 | in @ref{Package Naming} | |
15565 | for the most recent version; previous versions use the same name, suffixed | |
15566 | by @code{-} and the smallest prefix of the version number that may | |
15567 | distinguish the two versions. | |
ef5dd60a | 15568 | |
cf4a9129 LC |
15569 | The name inside the package definition is the same for all versions of a |
15570 | package and does not contain any version number. | |
ef5dd60a | 15571 | |
cf4a9129 | 15572 | For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows: |
ef5dd60a | 15573 | |
cf4a9129 LC |
15574 | @example |
15575 | (define-public gtk+ | |
15576 | (package | |
17d8e33f ML |
15577 | (name "gtk+") |
15578 | (version "3.9.12") | |
15579 | ...)) | |
cf4a9129 LC |
15580 | (define-public gtk+-2 |
15581 | (package | |
17d8e33f ML |
15582 | (name "gtk+") |
15583 | (version "2.24.20") | |
15584 | ...)) | |
cf4a9129 LC |
15585 | @end example |
15586 | If we also wanted GTK+ 3.8.2, this would be packaged as | |
15587 | @example | |
15588 | (define-public gtk+-3.8 | |
15589 | (package | |
17d8e33f ML |
15590 | (name "gtk+") |
15591 | (version "3.8.2") | |
15592 | ...)) | |
cf4a9129 | 15593 | @end example |
ef5dd60a | 15594 | |
880d647d LC |
15595 | @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>, |
15596 | @c for a discussion of what follows. | |
15597 | @cindex version number, for VCS snapshots | |
15598 | Occasionally, we package snapshots of upstream's version control system | |
15599 | (VCS) instead of formal releases. This should remain exceptional, | |
15600 | because it is up to upstream developers to clarify what the stable | |
15601 | release is. Yet, it is sometimes necessary. So, what should we put in | |
15602 | the @code{version} field? | |
15603 | ||
15604 | Clearly, we need to make the commit identifier of the VCS snapshot | |
15605 | visible in the version string, but we also need to make sure that the | |
15606 | version string is monotonically increasing so that @command{guix package | |
15607 | --upgrade} can determine which version is newer. Since commit | |
15608 | identifiers, notably with Git, are not monotonically increasing, we add | |
15609 | a revision number that we increase each time we upgrade to a newer | |
15610 | snapshot. The resulting version string looks like this: | |
15611 | ||
15612 | @example | |
15613 | 2.0.11-3.cabba9e | |
15614 | ^ ^ ^ | |
15615 | | | `-- upstream commit ID | |
15616 | | | | |
15617 | | `--- Guix package revision | |
15618 | | | |
15619 | latest upstream version | |
15620 | @end example | |
15621 | ||
15622 | It is a good idea to strip commit identifiers in the @code{version} | |
15623 | field to, say, 7 digits. It avoids an aesthetic annoyance (assuming | |
15624 | aesthetics have a role to play here) as well as problems related to OS | |
15625 | limits such as the maximum shebang length (127 bytes for the Linux | |
15626 | kernel.) It is best to use the full commit identifiers in | |
561360a5 LC |
15627 | @code{origin}s, though, to avoid ambiguities. A typical package |
15628 | definition may look like this: | |
15629 | ||
15630 | @example | |
15631 | (define my-package | |
6e42660b | 15632 | (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7") |
15633 | (revision "1")) ;Guix package revision | |
561360a5 | 15634 | (package |
6e42660b | 15635 | (version (string-append "0.9-" revision "." |
561360a5 LC |
15636 | (string-take commit 7))) |
15637 | (source (origin | |
15638 | (method git-fetch) | |
15639 | (uri (git-reference | |
15640 | (url "git://example.org/my-package.git") | |
15641 | (commit commit))) | |
15642 | (sha256 (base32 "1mbikn@dots{}")) | |
15643 | (file-name (string-append "my-package-" version | |
15644 | "-checkout")))) | |
15645 | ;; @dots{} | |
15646 | ))) | |
15647 | @end example | |
880d647d | 15648 | |
cbd02397 LC |
15649 | @node Synopses and Descriptions |
15650 | @subsection Synopses and Descriptions | |
15651 | ||
e32171ee JD |
15652 | @cindex package description |
15653 | @cindex package synopsis | |
cbd02397 LC |
15654 | As we have seen before, each package in GNU@tie{}Guix includes a |
15655 | synopsis and a description (@pxref{Defining Packages}). Synopses and | |
15656 | descriptions are important: They are what @command{guix package | |
15657 | --search} searches, and a crucial piece of information to help users | |
15658 | determine whether a given package suits their needs. Consequently, | |
15659 | packagers should pay attention to what goes into them. | |
15660 | ||
15661 | Synopses must start with a capital letter and must not end with a | |
15662 | period. They must not start with ``a'' or ``the'', which usually does | |
15663 | not bring anything; for instance, prefer ``File-frobbing tool'' over ``A | |
15664 | tool that frobs files''. The synopsis should say what the package | |
15665 | is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is | |
15666 | used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines | |
15667 | matching a pattern''. | |
15668 | ||
15669 | Keep in mind that the synopsis must be meaningful for a very wide | |
15670 | audience. For example, ``Manipulate alignments in the SAM format'' | |
15671 | might make sense for a seasoned bioinformatics researcher, but might be | |
15672 | fairly unhelpful or even misleading to a non-specialized audience. It | |
15673 | is a good idea to come up with a synopsis that gives an idea of the | |
15674 | application domain of the package. In this example, this might give | |
15675 | something like ``Manipulate nucleotide sequence alignments'', which | |
15676 | hopefully gives the user a better idea of whether this is what they are | |
15677 | looking for. | |
15678 | ||
cbd02397 LC |
15679 | Descriptions should take between five and ten lines. Use full |
15680 | sentences, and avoid using acronyms without first introducing them. | |
762e54b7 LC |
15681 | Please avoid marketing phrases such as ``world-leading'', |
15682 | ``industrial-strength'', and ``next-generation'', and avoid superlatives | |
15683 | like ``the most advanced''---they are not helpful to users looking for a | |
15684 | package and may even sound suspicious. Instead, try to be factual, | |
15685 | mentioning use cases and features. | |
15686 | ||
15687 | @cindex Texinfo markup, in package descriptions | |
cbd02397 LC |
15688 | Descriptions can include Texinfo markup, which is useful to introduce |
15689 | ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or | |
ba7d6c76 ML |
15690 | hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you |
15691 | should be careful when using some characters for example @samp{@@} and | |
15692 | curly braces which are the basic special characters in Texinfo | |
15693 | (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces | |
15694 | such as @command{guix package --show} take care of rendering it | |
15695 | appropriately. | |
cbd02397 LC |
15696 | |
15697 | Synopses and descriptions are translated by volunteers | |
15698 | @uref{http://translationproject.org/domain/guix-packages.html, at the | |
15699 | Translation Project} so that as many users as possible can read them in | |
15700 | their native language. User interfaces search them and display them in | |
15701 | the language specified by the current locale. | |
15702 | ||
15703 | Translation is a lot of work so, as a packager, please pay even more | |
15704 | attention to your synopses and descriptions as every change may entail | |
ba7d6c76 | 15705 | additional work for translators. In order to help them, it is possible |
36743e71 | 15706 | to make recommendations or instructions visible to them by inserting |
ba7d6c76 ML |
15707 | special comments like this (@pxref{xgettext Invocation,,, gettext, GNU |
15708 | Gettext}): | |
15709 | ||
15710 | @example | |
15711 | ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated. | |
15712 | (description "ARandR is designed to provide a simple visual front end | |
15713 | for the X11 resize-and-rotate (RandR) extension. @dots{}") | |
15714 | @end example | |
cbd02397 | 15715 | |
ef5dd60a | 15716 | |
cf4a9129 LC |
15717 | @node Python Modules |
15718 | @subsection Python Modules | |
ef5dd60a | 15719 | |
e32171ee | 15720 | @cindex python |
cf4a9129 LC |
15721 | We currently package Python 2 and Python 3, under the Scheme variable names |
15722 | @code{python-2} and @code{python} as explained in @ref{Version Numbers}. | |
15723 | To avoid confusion and naming clashes with other programming languages, it | |
15724 | seems desirable that the name of a package for a Python module contains | |
15725 | the word @code{python}. | |
ef5dd60a | 15726 | |
cf4a9129 LC |
15727 | Some modules are compatible with only one version of Python, others with both. |
15728 | If the package Foo compiles only with Python 3, we name it | |
15729 | @code{python-foo}; if it compiles only with Python 2, we name it | |
15730 | @code{python2-foo}. If it is compatible with both versions, we create two | |
15731 | packages with the corresponding names. | |
ef5dd60a | 15732 | |
cf4a9129 LC |
15733 | If a project already contains the word @code{python}, we drop this; |
15734 | for instance, the module python-dateutil is packaged under the names | |
99c866a0 HG |
15735 | @code{python-dateutil} and @code{python2-dateutil}. If the project name |
15736 | starts with @code{py} (e.g. @code{pytz}), we keep it and prefix it as | |
15737 | described above. | |
113daf62 | 15738 | |
e940a271 HG |
15739 | @subsubsection Specifying Dependencies |
15740 | @cindex inputs, for Python packages | |
15741 | ||
15742 | Dependency information for Python packages is usually available in the | |
15743 | package source tree, with varying degrees of accuracy: in the | |
15744 | @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}. | |
15745 | ||
15746 | Your mission, when writing a recipe for a Python package, is to map | |
15747 | these dependencies to the appropriate type of ``input'' (@pxref{package | |
15748 | Reference, inputs}). Although the @code{pypi} importer normally does a | |
15749 | good job (@pxref{Invoking guix import}), you may want to check the | |
15750 | following check list to determine which dependency goes where. | |
15751 | ||
15752 | @itemize | |
15753 | ||
aaf75c89 HG |
15754 | @item |
15755 | We currently package Python 2 with @code{setuptools} and @code{pip} | |
15756 | installed like Python 3.4 has per default. Thus you don't need to | |
891a843d HG |
15757 | specify either of these as an input. @command{guix lint} will warn you |
15758 | if you do. | |
aaf75c89 | 15759 | |
e940a271 HG |
15760 | @item |
15761 | Python dependencies required at run time go into | |
15762 | @code{propagated-inputs}. They are typically defined with the | |
15763 | @code{install_requires} keyword in @file{setup.py}, or in the | |
15764 | @file{requirements.txt} file. | |
15765 | ||
15766 | @item | |
15767 | Python packages required only at build time---e.g., those listed with | |
15768 | the @code{setup_requires} keyword in @file{setup.py}---or only for | |
15769 | testing---e.g., those in @code{tests_require}---go into | |
15770 | @code{native-inputs}. The rationale is that (1) they do not need to be | |
15771 | propagated because they are not needed at run time, and (2) in a | |
15772 | cross-compilation context, it's the ``native'' input that we'd want. | |
15773 | ||
aaf75c89 | 15774 | Examples are the @code{pytest}, @code{mock}, and @code{nose} test |
e940a271 HG |
15775 | frameworks. Of course if any of these packages is also required at |
15776 | run-time, it needs to go to @code{propagated-inputs}. | |
15777 | ||
15778 | @item | |
15779 | Anything that does not fall in the previous categories goes to | |
15780 | @code{inputs}, for example programs or C libraries required for building | |
15781 | Python packages containing C extensions. | |
15782 | ||
15783 | @item | |
15784 | If a Python package has optional dependencies (@code{extras_require}), | |
15785 | it is up to you to decide whether to add them or not, based on their | |
15786 | usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix | |
15787 | size}}). | |
15788 | ||
15789 | @end itemize | |
15790 | ||
15791 | ||
cf4a9129 LC |
15792 | @node Perl Modules |
15793 | @subsection Perl Modules | |
523e4896 | 15794 | |
e32171ee | 15795 | @cindex perl |
cf4a9129 LC |
15796 | Perl programs standing for themselves are named as any other package, |
15797 | using the lowercase upstream name. | |
15798 | For Perl packages containing a single class, we use the lowercase class name, | |
15799 | replace all occurrences of @code{::} by dashes and prepend the prefix | |
15800 | @code{perl-}. | |
15801 | So the class @code{XML::Parser} becomes @code{perl-xml-parser}. | |
15802 | Modules containing several classes keep their lowercase upstream name and | |
15803 | are also prepended by @code{perl-}. Such modules tend to have the word | |
15804 | @code{perl} somewhere in their name, which gets dropped in favor of the | |
15805 | prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}. | |
523e4896 | 15806 | |
523e4896 | 15807 | |
e1c963bf HG |
15808 | @node Java Packages |
15809 | @subsection Java Packages | |
15810 | ||
e32171ee | 15811 | @cindex java |
e1c963bf HG |
15812 | Java programs standing for themselves are named as any other package, |
15813 | using the lowercase upstream name. | |
15814 | ||
15815 | To avoid confusion and naming clashes with other programming languages, | |
15816 | it is desirable that the name of a package for a Java package is | |
15817 | prefixed with @code{java-}. If a project already contains the word | |
15818 | @code{java}, we drop this; for instance, the package @code{ngsjava} is | |
15819 | packaged under the name @code{java-ngs}. | |
15820 | ||
15821 | For Java packages containing a single class or a small class hierarchy, | |
15822 | we use the lowercase class name, replace all occurrences of @code{.} by | |
15823 | dashes and prepend the prefix @code{java-}. So the class | |
15824 | @code{apache.commons.cli} becomes package | |
15825 | @code{java-apache-commons-cli}. | |
15826 | ||
15827 | ||
7fec52b7 AE |
15828 | @node Fonts |
15829 | @subsection Fonts | |
15830 | ||
e32171ee | 15831 | @cindex fonts |
7fec52b7 AE |
15832 | For fonts that are in general not installed by a user for typesetting |
15833 | purposes, or that are distributed as part of a larger software package, | |
15834 | we rely on the general packaging rules for software; for instance, this | |
15835 | applies to the fonts delivered as part of the X.Org system or fonts that | |
15836 | are part of TeX Live. | |
15837 | ||
15838 | To make it easier for a user to search for fonts, names for other packages | |
15839 | containing only fonts are constructed as follows, independently of the | |
15840 | upstream package name. | |
15841 | ||
15842 | The name of a package containing only one font family starts with | |
15843 | @code{font-}; it is followed by the foundry name and a dash @code{-} | |
15844 | if the foundry is known, and the font family name, in which spaces are | |
15845 | replaced by dashes (and as usual, all upper case letters are transformed | |
15846 | to lower case). | |
15847 | For example, the Gentium font family by SIL is packaged under the name | |
15848 | @code{font-sil-gentium}. | |
15849 | ||
15850 | For a package containing several font families, the name of the collection | |
15851 | is used in the place of the font family name. | |
15852 | For instance, the Liberation fonts consist of three families, | |
15853 | Liberation Sans, Liberation Serif and Liberation Mono. | |
15854 | These could be packaged separately under the names | |
15855 | @code{font-liberation-sans} and so on; but as they are distributed together | |
15856 | under a common name, we prefer to package them together as | |
15857 | @code{font-liberation}. | |
15858 | ||
15859 | In the case where several formats of the same font family or font collection | |
15860 | are packaged separately, a short form of the format, prepended by a dash, | |
15861 | is added to the package name. We use @code{-ttf} for TrueType fonts, | |
1b366ee4 | 15862 | @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1 |
7fec52b7 AE |
15863 | fonts. |
15864 | ||
15865 | ||
b25937e3 | 15866 | |
cf4a9129 LC |
15867 | @node Bootstrapping |
15868 | @section Bootstrapping | |
b25937e3 | 15869 | |
cf4a9129 | 15870 | @c Adapted from the ELS 2013 paper. |
b25937e3 | 15871 | |
cf4a9129 | 15872 | @cindex bootstrapping |
7889394e | 15873 | |
cf4a9129 LC |
15874 | Bootstrapping in our context refers to how the distribution gets built |
15875 | ``from nothing''. Remember that the build environment of a derivation | |
15876 | contains nothing but its declared inputs (@pxref{Introduction}). So | |
15877 | there's an obvious chicken-and-egg problem: how does the first package | |
15878 | get built? How does the first compiler get compiled? Note that this is | |
15879 | a question of interest only to the curious hacker, not to the regular | |
15880 | user, so you can shamelessly skip this section if you consider yourself | |
15881 | a ``regular user''. | |
72b9d60d | 15882 | |
cf4a9129 LC |
15883 | @cindex bootstrap binaries |
15884 | The GNU system is primarily made of C code, with libc at its core. The | |
15885 | GNU build system itself assumes the availability of a Bourne shell and | |
15886 | command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and | |
15887 | `grep'. Furthermore, build programs---programs that run | |
15888 | @code{./configure}, @code{make}, etc.---are written in Guile Scheme | |
15889 | (@pxref{Derivations}). Consequently, to be able to build anything at | |
15890 | all, from scratch, Guix relies on pre-built binaries of Guile, GCC, | |
15891 | Binutils, libc, and the other packages mentioned above---the | |
15892 | @dfn{bootstrap binaries}. | |
72b9d60d | 15893 | |
cf4a9129 LC |
15894 | These bootstrap binaries are ``taken for granted'', though we can also |
15895 | re-create them if needed (more on that later). | |
72b9d60d | 15896 | |
cf4a9129 | 15897 | @unnumberedsubsec Preparing to Use the Bootstrap Binaries |
c79d54fe | 15898 | |
cf4a9129 LC |
15899 | @c As of Emacs 24.3, Info-mode displays the image, but since it's a |
15900 | @c large image, it's hard to scroll. Oh well. | |
15901 | @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations} | |
523e4896 | 15902 | |
cf4a9129 LC |
15903 | The figure above shows the very beginning of the dependency graph of the |
15904 | distribution, corresponding to the package definitions of the @code{(gnu | |
d33fa0c7 LC |
15905 | packages bootstrap)} module. A similar figure can be generated with |
15906 | @command{guix graph} (@pxref{Invoking guix graph}), along the lines of: | |
15907 | ||
15908 | @example | |
15909 | guix graph -t derivation \ | |
15910 | -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \ | |
15911 | | dot -Tps > t.ps | |
15912 | @end example | |
15913 | ||
15914 | At this level of detail, things are | |
cf4a9129 LC |
15915 | slightly complex. First, Guile itself consists of an ELF executable, |
15916 | along with many source and compiled Scheme files that are dynamically | |
15917 | loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz} | |
15918 | tarball shown in this graph. This tarball is part of Guix's ``source'' | |
15919 | distribution, and gets inserted into the store with @code{add-to-store} | |
15920 | (@pxref{The Store}). | |
2e7b5cea | 15921 | |
cf4a9129 LC |
15922 | But how do we write a derivation that unpacks this tarball and adds it |
15923 | to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv} | |
15924 | derivation---the first one that gets built---uses @code{bash} as its | |
15925 | builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls | |
15926 | @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar}, | |
15927 | @file{xz}, and @file{mkdir} are statically-linked binaries, also part of | |
15928 | the Guix source distribution, whose sole purpose is to allow the Guile | |
15929 | tarball to be unpacked. | |
fb729425 | 15930 | |
cf4a9129 LC |
15931 | Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning |
15932 | Guile that can be used to run subsequent build programs. Its first task | |
15933 | is to download tarballs containing the other pre-built binaries---this | |
15934 | is what the @code{.tar.xz.drv} derivations do. Guix modules such as | |
15935 | @code{ftp-client.scm} are used for this purpose. The | |
15936 | @code{module-import.drv} derivations import those modules in a directory | |
15937 | in the store, using the original layout. The | |
15938 | @code{module-import-compiled.drv} derivations compile those modules, and | |
15939 | write them in an output directory with the right layout. This | |
15940 | corresponds to the @code{#:modules} argument of | |
15941 | @code{build-expression->derivation} (@pxref{Derivations}). | |
fb729425 | 15942 | |
cf4a9129 LC |
15943 | Finally, the various tarballs are unpacked by the |
15944 | derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, | |
15945 | etc., at which point we have a working C tool chain. | |
fb729425 | 15946 | |
fb729425 | 15947 | |
cf4a9129 | 15948 | @unnumberedsubsec Building the Build Tools |
523e4896 | 15949 | |
cf4a9129 LC |
15950 | Bootstrapping is complete when we have a full tool chain that does not |
15951 | depend on the pre-built bootstrap tools discussed above. This | |
15952 | no-dependency requirement is verified by checking whether the files of | |
15953 | the final tool chain contain references to the @file{/gnu/store} | |
15954 | directories of the bootstrap inputs. The process that leads to this | |
15955 | ``final'' tool chain is described by the package definitions found in | |
1f6f57df | 15956 | the @code{(gnu packages commencement)} module. |
df2ce343 | 15957 | |
d33fa0c7 LC |
15958 | The @command{guix graph} command allows us to ``zoom out'' compared to |
15959 | the graph above, by looking at the level of package objects instead of | |
15960 | individual derivations---remember that a package may translate to | |
15961 | several derivations, typically one derivation to download its source, | |
15962 | one to build the Guile modules it needs, and one to actually build the | |
15963 | package from source. The command: | |
15964 | ||
15965 | @example | |
15966 | guix graph -t bag \ | |
15967 | -e '(@@@@ (gnu packages commencement) | |
15968 | glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps | |
15969 | @end example | |
15970 | ||
15971 | @noindent | |
15972 | produces the dependency graph leading to the ``final'' C | |
15973 | library@footnote{You may notice the @code{glibc-intermediate} label, | |
15974 | suggesting that it is not @emph{quite} final, but as a good | |
15975 | approximation, we will consider it final.}, depicted below. | |
15976 | ||
15977 | @image{images/bootstrap-packages,6in,,Dependency graph of the early packages} | |
15978 | ||
cf4a9129 LC |
15979 | @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>. |
15980 | The first tool that gets built with the bootstrap binaries is | |
d33fa0c7 LC |
15981 | GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite |
15982 | for all the following packages. From there Findutils and Diffutils get | |
15983 | built. | |
523e4896 | 15984 | |
cf4a9129 LC |
15985 | Then come the first-stage Binutils and GCC, built as pseudo cross |
15986 | tools---i.e., with @code{--target} equal to @code{--host}. They are | |
15987 | used to build libc. Thanks to this cross-build trick, this libc is | |
15988 | guaranteed not to hold any reference to the initial tool chain. | |
4af2447e | 15989 | |
d33fa0c7 LC |
15990 | From there the final Binutils and GCC (not shown above) are built. |
15991 | GCC uses @code{ld} | |
cf4a9129 LC |
15992 | from the final Binutils, and links programs against the just-built libc. |
15993 | This tool chain is used to build the other packages used by Guix and by | |
15994 | the GNU Build System: Guile, Bash, Coreutils, etc. | |
4af2447e | 15995 | |
cf4a9129 LC |
15996 | And voilà! At this point we have the complete set of build tools that |
15997 | the GNU Build System expects. These are in the @code{%final-inputs} | |
dd164244 MW |
15998 | variable of the @code{(gnu packages commencement)} module, and are |
15999 | implicitly used by any package that uses @code{gnu-build-system} | |
1f6f57df | 16000 | (@pxref{Build Systems, @code{gnu-build-system}}). |
4af2447e | 16001 | |
4af2447e | 16002 | |
cf4a9129 | 16003 | @unnumberedsubsec Building the Bootstrap Binaries |
4af2447e | 16004 | |
e32171ee | 16005 | @cindex bootstrap binaries |
cf4a9129 LC |
16006 | Because the final tool chain does not depend on the bootstrap binaries, |
16007 | those rarely need to be updated. Nevertheless, it is useful to have an | |
16008 | automated way to produce them, should an update occur, and this is what | |
16009 | the @code{(gnu packages make-bootstrap)} module provides. | |
4af2447e | 16010 | |
cf4a9129 LC |
16011 | The following command builds the tarballs containing the bootstrap |
16012 | binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture | |
16013 | of Coreutils and other basic command-line tools): | |
4b2615e1 | 16014 | |
cf4a9129 LC |
16015 | @example |
16016 | guix build bootstrap-tarballs | |
16017 | @end example | |
16018 | ||
16019 | The generated tarballs are those that should be referred to in the | |
16020 | @code{(gnu packages bootstrap)} module mentioned at the beginning of | |
16021 | this section. | |
16022 | ||
16023 | Still here? Then perhaps by now you've started to wonder: when do we | |
16024 | reach a fixed point? That is an interesting question! The answer is | |
16025 | unknown, but if you would like to investigate further (and have | |
16026 | significant computational and storage resources to do so), then let us | |
16027 | know. | |
16028 | ||
16029 | @node Porting | |
16030 | @section Porting to a New Platform | |
16031 | ||
16032 | As discussed above, the GNU distribution is self-contained, and | |
16033 | self-containment is achieved by relying on pre-built ``bootstrap | |
16034 | binaries'' (@pxref{Bootstrapping}). These binaries are specific to an | |
16035 | operating system kernel, CPU architecture, and application binary | |
16036 | interface (ABI). Thus, to port the distribution to a platform that is | |
16037 | not yet supported, one must build those bootstrap binaries, and update | |
16038 | the @code{(gnu packages bootstrap)} module to use them on that platform. | |
16039 | ||
16040 | Fortunately, Guix can @emph{cross compile} those bootstrap binaries. | |
16041 | When everything goes well, and assuming the GNU tool chain supports the | |
16042 | target platform, this can be as simple as running a command like this | |
16043 | one: | |
16044 | ||
16045 | @example | |
16046 | guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs | |
16047 | @end example | |
16048 | ||
1c0c417d LC |
16049 | For this to work, the @code{glibc-dynamic-linker} procedure in |
16050 | @code{(gnu packages bootstrap)} must be augmented to return the right | |
16051 | file name for libc's dynamic linker on that platform; likewise, | |
16052 | @code{system->linux-architecture} in @code{(gnu packages linux)} must be | |
16053 | taught about the new platform. | |
16054 | ||
cf4a9129 | 16055 | Once these are built, the @code{(gnu packages bootstrap)} module needs |
1c0c417d LC |
16056 | to be updated to refer to these binaries on the target platform. That |
16057 | is, the hashes and URLs of the bootstrap tarballs for the new platform | |
16058 | must be added alongside those of the currently supported platforms. The | |
16059 | bootstrap Guile tarball is treated specially: it is expected to be | |
03d0e2d2 | 16060 | available locally, and @file{gnu/local.mk} has rules do download it for |
1c0c417d LC |
16061 | the supported architectures; a rule for the new platform must be added |
16062 | as well. | |
cf4a9129 LC |
16063 | |
16064 | In practice, there may be some complications. First, it may be that the | |
16065 | extended GNU triplet that specifies an ABI (like the @code{eabi} suffix | |
16066 | above) is not recognized by all the GNU tools. Typically, glibc | |
16067 | recognizes some of these, whereas GCC uses an extra @code{--with-abi} | |
16068 | configure flag (see @code{gcc.scm} for examples of how to handle this). | |
16069 | Second, some of the required packages could fail to build for that | |
16070 | platform. Lastly, the generated binaries could be broken for some | |
16071 | reason. | |
4af2447e | 16072 | |
9bf3c1a7 | 16073 | @c ********************************************************************* |
8c01b9d0 | 16074 | @include contributing.texi |
c78bd12b | 16075 | |
568717fd LC |
16076 | @c ********************************************************************* |
16077 | @node Acknowledgments | |
16078 | @chapter Acknowledgments | |
16079 | ||
136787cb LC |
16080 | Guix is based on the @uref{http://nixos.org/nix/, Nix package manager}, |
16081 | which was designed and | |
4c7ac9aa LC |
16082 | implemented by Eelco Dolstra, with contributions from other people (see |
16083 | the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package | |
568717fd LC |
16084 | management, and promoted unprecedented features, such as transactional |
16085 | package upgrades and rollbacks, per-user profiles, and referentially | |
16086 | transparent build processes. Without this work, Guix would not exist. | |
16087 | ||
16088 | The Nix-based software distributions, Nixpkgs and NixOS, have also been | |
16089 | an inspiration for Guix. | |
16090 | ||
4c7ac9aa LC |
16091 | GNU@tie{}Guix itself is a collective work with contributions from a |
16092 | number of people. See the @file{AUTHORS} file in Guix for more | |
16093 | information on these fine people. The @file{THANKS} file lists people | |
16094 | who have helped by reporting bugs, taking care of the infrastructure, | |
16095 | providing artwork and themes, making suggestions, and more---thank you! | |
16096 | ||
16097 | ||
568717fd LC |
16098 | @c ********************************************************************* |
16099 | @node GNU Free Documentation License | |
16100 | @appendix GNU Free Documentation License | |
e32171ee | 16101 | @cindex license, GNU Free Documentation License |
568717fd LC |
16102 | @include fdl-1.3.texi |
16103 | ||
16104 | @c ********************************************************************* | |
16105 | @node Concept Index | |
16106 | @unnumbered Concept Index | |
16107 | @printindex cp | |
16108 | ||
a85b83d2 LC |
16109 | @node Programming Index |
16110 | @unnumbered Programming Index | |
16111 | @syncodeindex tp fn | |
16112 | @syncodeindex vr fn | |
568717fd LC |
16113 | @printindex fn |
16114 | ||
16115 | @bye | |
16116 | ||
16117 | @c Local Variables: | |
16118 | @c ispell-local-dictionary: "american"; | |
16119 | @c End: |