summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-10-28 21:36:07 +0100
committerLudovic Courtès <ludo@gnu.org>2015-10-28 21:58:25 +0100
commitcd6f6c22fb581e5ef2aa88f5e9c14a4c54a071c3 (patch)
tree2cb4a58c45015d81b11b9c2d552920da5f111f78 /doc
parentb0b9f6e0a62852a0b4d0a86d9e8427dd7d36a714 (diff)
services: Add 'modify-services'.
* gnu/services.scm (%modify-service, modify-services): New macros. * gnu/services/base.scm (mingetty-service-type, guix-service-type): Export. * emacs/guix-devel.el (guix-devel-keywords): Add 'modify-services'. Ditto in 'guix-devel-scheme-indent' call. * doc/guix.texi (Using the Configuration System): Give an example of 'modify-services'. (Service Reference): Document it.
Diffstat (limited to 'doc')
-rw-r--r--doc/guix.texi73
1 files changed, 67 insertions, 6 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 0a3827911bf..01e28041f21 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5363,16 +5363,40 @@ The @code{services} field lists @dfn{system services} to be made
5363available when the system starts (@pxref{Services}). 5363available when the system starts (@pxref{Services}).
5364The @code{operating-system} declaration above specifies that, in 5364The @code{operating-system} declaration above specifies that, in
5365addition to the basic services, we want the @command{lshd} secure shell 5365addition to the basic services, we want the @command{lshd} secure shell
5366daemon listening on port 2222, and allowing remote @code{root} logins 5366daemon listening on port 2222 (@pxref{Networking Services,
5367(@pxref{Invoking lshd,,, lsh, GNU lsh Manual}). Under the hood, 5367@code{lsh-service}}). Under the hood,
5368@code{lsh-service} arranges so that @code{lshd} is started with the 5368@code{lsh-service} arranges so that @code{lshd} is started with the
5369right command-line options, possibly with supporting configuration files 5369right command-line options, possibly with supporting configuration files
5370generated as needed (@pxref{Defining Services}). @xref{operating-system 5370generated as needed (@pxref{Defining Services}).
5371Reference}, for details about the available @code{operating-system} 5371
5372fields. 5372@cindex customization, of services
5373@findex modify-services
5374Occasionally, instead of using the base services as is, you will want to
5375customize them. For instance, to change the configuration of
5376@code{guix-daemon} and Mingetty (the console log-in), you may write the
5377following instead of @var{%base-services}:
5378
5379@lisp
5380(modify-services %base-services
5381 (guix-service-type config =>
5382 (guix-configuration
5383 (inherit config)
5384 (use-substitutes? #f)
5385 (extra-options '("--gc-keep-outputs"))))
5386 (mingetty-service-type config =>
5387 (mingetty-configuration
5388 (inherit config)
5389 (motd (plain-file "motd" "Hi there!")))))
5390@end lisp
5391
5392@noindent
5393The effect here is to change the options passed to @command{guix-daemon}
5394when it is started, as well as the ``message of the day'' that appears
5395when logging in at the console. @xref{Service Reference,
5396@code{modify-services}}, for more on that.
5373 5397
5374The configuration for a typical ``desktop'' usage, with the X11 display 5398The configuration for a typical ``desktop'' usage, with the X11 display
5375server, a desktop environment, network management, an SSH server, and 5399server, a desktop environment, network management, power management, and
5376more, would look like this: 5400more, would look like this:
5377 5401
5378@lisp 5402@lisp
@@ -5382,6 +5406,8 @@ more, would look like this:
5382@xref{Desktop Services}, for the exact list of services provided by 5406@xref{Desktop Services}, for the exact list of services provided by
5383@var{%desktop-services}. @xref{X.509 Certificates}, for background 5407@var{%desktop-services}. @xref{X.509 Certificates}, for background
5384information about the @code{nss-certs} package that is used here. 5408information about the @code{nss-certs} package that is used here.
5409@xref{operating-system Reference}, for details about all the available
5410@code{operating-system} fields.
5385 5411
5386Assuming the above snippet is stored in the @file{my-system-config.scm} 5412Assuming the above snippet is stored in the @file{my-system-config.scm}
5387file, the @command{guix system reconfigure my-system-config.scm} command 5413file, the @command{guix system reconfigure my-system-config.scm} command
@@ -7539,6 +7565,41 @@ Here is an example of how a service is created and manipulated:
7539@result{} #t 7565@result{} #t
7540@end example 7566@end example
7541 7567
7568The @code{modify-services} form provides a handy way to change the
7569parameters of some of the services of a list such as
7570@var{%base-services} (@pxref{Base Services, @code{%base-services}}). Of
7571course, you could always use standard list combinators such as
7572@code{map} and @code{fold} to do that (@pxref{SRFI-1, List Library,,
7573guile, GNU Guile Reference Manual}); @code{modify-services} simply
7574provides a more concise form for this common pattern.
7575
7576@deffn {Scheme Syntax} modify-services @var{services} @
7577 (@var{type} @var{variable} => @var{body}) @dots{}
7578
7579Modify the services listed in @var{services} according to the given
7580clauses. Each clause has the form:
7581
7582@example
7583(@var{type} @var{variable} => @var{body})
7584@end example
7585
7586where @var{type} is a service type, such as @var{guix-service-type}, and
7587@var{variable} is an identifier that is bound within @var{body} to the
7588value of the service of that @var{type}. @xref{Using the Configuration
7589System}, for an example.
7590
7591This is a shorthand for:
7592
7593@example
7594(map (lambda (service) @dots{}) @var{services})
7595@end example
7596@end deffn
7597
7598Next comes the programming interface for service types. This is
7599something you want to know when writing new service definitions, but not
7600necessarily when simply looking for ways to customize your
7601@code{operating-system} declaration.
7602
7542@deftp {Data Type} service-type 7603@deftp {Data Type} service-type
7543@cindex service type 7604@cindex service type
7544This is the representation of a @dfn{service type} (@pxref{Service Types 7605This is the representation of a @dfn{service type} (@pxref{Service Types