From: Chris Marusich <cmmarusich@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] doc: Clarify and consolidate modify-services documentation.
Date: Sat, 12 Mar 2016 03:38:54 -0800 [thread overview]
Message-ID: <87h9gchqnl.fsf@gmail.com> (raw)
In-Reply-To: <87lh5ohr1z.fsf@gmail.com> (Chris Marusich's message of "Sat, 12 Mar 2016 03:30:16 -0800")
[-- Attachment #1: Type: text/plain, Size: 167 bytes --]
Whoops, there was a missing brace in my patch, so make couldn't build
the documentation. Here's a new patch which adds the missing brace.
Sorry for the double post!
[-- Attachment #2: 0001-doc-Clarify-and-consolidate-modify-services-document.patch --]
[-- Type: text/x-patch, Size: 8679 bytes --]
From bf03c0a3fa35144342849cdf550219a185fbf10d Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Mon, 7 Mar 2016 01:55:07 -0800
Subject: [PATCH] doc: Clarify and consolidate modify-services documentation.
* doc/guix.texi ("Using the Configuration System": Move the example...
* doc/guix.texi ("Service Reference"): ...to here, and clarify more.
* gnu/services.scm (modify-services): Update docstring to match.
---
doc/guix.texi | 79 ++++++++++++++++++++++++++++++++++----------------------
gnu/services.scm | 39 +++++++++++-----------------
2 files changed, 63 insertions(+), 55 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index f7deafa..29e73bf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18,6 +18,7 @@ Copyright @copyright{} 2014 Pierre-Antoine Rault@*
Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
Copyright @copyright{} 2015, 2016 Leo Famulari
Copyright @copyright{} 2016 Ben Woodcroft
+Copyright @copyright{} 2016 Chris Marusich
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -6087,28 +6088,38 @@ generated as needed (@pxref{Defining Services}).
@cindex customization, of services
@findex modify-services
Occasionally, instead of using the base services as is, you will want to
-customize them. For instance, to change the configuration of
-@code{guix-daemon} and Mingetty (the console log-in), you may write the
-following instead of @var{%base-services}:
+customize them. To do this, use @code{modify-services} (@pxref{Service
+Reference, @code{modify-services}}) to modify the list.
+
+For example, suppose you want to modify @code{guix-daemon} and Mingetty
+(the console log-in) in the @var{%base-services} list (@pxref{Base
+Services, @code{%base-services}). To do that, you could write the
+following in your operating system declaration:
@lisp
-(modify-services %base-services
- (guix-service-type config =>
- (guix-configuration
- (inherit config)
- (use-substitutes? #f)
- (extra-options '("--gc-keep-outputs"))))
- (mingetty-service-type config =>
- (mingetty-configuration
- (inherit config)
- (motd (plain-file "motd" "Hi there!")))))
+(operating-system
+ ;; @dots{}
+ (services (modify-services %base-services
+ (guix-service-type config =>
+ (guix-configuration
+ (inherit config)
+ (use-substitutes? #f)
+ (extra-options '("--gc-keep-derivations"))))
+ (mingetty-service-type config =>
+ (mingetty-configuration
+ (inherit config)
+ (motd (plain-file "motd" "Hi there!"))))))
@end lisp
-@noindent
-The effect here is to change the options passed to @command{guix-daemon}
-when it is started, as well as the ``message of the day'' that appears
-when logging in at the console. @xref{Service Reference,
-@code{modify-services}}, for more on that.
+This changes the configuration---i.e., the service parameters---of the
+@code{guix-service-type} instance, and that of all the
+@code{mingetty-service-type} instances in the @var{%base-services} list.
+Observe how this is accomplished: first, we arrange for the original
+configuration to be bound to the identifier @code{config} in the
+@var{body}, and then we write the @var{body} so that it evaluates to the
+desired configuration. In particular, notice how we use @code{inherit}
+to create a new configuration which has the same values as the old
+configuration, but with a few modifications.
The configuration for a typical ``desktop'' usage, with the X11 display
server, a desktop environment, network management, power management, and
@@ -9963,11 +9974,12 @@ Here is an example of how a service is created and manipulated:
The @code{modify-services} form provides a handy way to change the
parameters of some of the services of a list such as
-@var{%base-services} (@pxref{Base Services, @code{%base-services}}). Of
-course, you could always use standard list combinators such as
-@code{map} and @code{fold} to do that (@pxref{SRFI-1, List Library,,
-guile, GNU Guile Reference Manual}); @code{modify-services} simply
-provides a more concise form for this common pattern.
+@var{%base-services} (@pxref{Base Services, @code{%base-services}}). It
+evalutes to a list of services. Of course, you could always use
+standard list combinators such as @code{map} and @code{fold} to do that
+(@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
+@code{modify-services} simply provides a more concise form for this
+common pattern.
@deffn {Scheme Syntax} modify-services @var{services} @
(@var{type} @var{variable} => @var{body}) @dots{}
@@ -9979,16 +9991,21 @@ clauses. Each clause has the form:
(@var{type} @var{variable} => @var{body})
@end example
-where @var{type} is a service type, such as @var{guix-service-type}, and
-@var{variable} is an identifier that is bound within @var{body} to the
-value of the service of that @var{type}. @xref{Using the Configuration
-System}, for an example.
+where @var{type} is a service type---e.g.,
+@code{guix-service-type}---and @var{variable} is an identifier that is
+bound within the @var{body} to the service parameters---e.g., a
+@code{guix-configuration} instance---of the original service of that
+@var{type}.
-This is a shorthand for:
+The @var{body} should evaluate to the new service parameters, which will
+be used to configure the new service. This new service will replace the
+original in the resulting list. Because a service's service parameters
+are created using @code{define-record-type*}, you can write a succint
+@var{body} that evaluates to the new service parameters by using the
+@code{inherit} feature that @code{define-record-type*} provides.
+
+@xref{Using the Configuration System} for example usage.
-@example
-(map (lambda (service) @dots{}) @var{services})
-@end example
@end deffn
Next comes the programming interface for service types. This is
diff --git a/gnu/services.scm b/gnu/services.scm
index cff6ed3..4fb5328 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -153,30 +154,20 @@
(define-syntax modify-services
(syntax-rules ()
- "Modify the services listed in SERVICES according to CLAUSES. Each clause
-must have the form:
-
- (TYPE VARIABLE => BODY)
-
-where TYPE is a service type, such as 'guix-service-type', and VARIABLE is an
-identifier that is bound within BODY to the value of the service of that
-TYPE. Consider this example:
-
- (modify-services %base-services
- (guix-service-type config =>
- (guix-configuration
- (inherit config)
- (use-substitutes? #f)
- (extra-options '(\"--gc-keep-derivations\"))))
- (mingetty-service-type config =>
- (mingetty-configuration
- (inherit config)
- (motd (plain-file \"motd\" \"Hi there!\")))))
-
-It changes the configuration of the GUIX-SERVICE-TYPE instance, and that of
-all the MINGETTY-SERVICE-TYPE instances.
-
-This is a shorthand for (map (lambda (svc) ...) %base-services)."
+ "Modify the services in the SERVICES list according to the given
+clauses. This form evaluates to a list of services. Each clause has
+the form:
+
+(TYPE VARIABLE => BODY)
+
+where TYPE is a service type---e.g., 'guix-service-type'---and
+VARIABLE is an identifier that is bound within the BODY to the service
+parameters---e.g., a 'guix-configuration' instance---of the original
+service of that TYPE.
+
+The BODY should evaluate to the new service parameters, which will be
+used to configure the new service. This new service will replace the
+original in the resulting list."
((_ services clauses ...)
(map (lambda (service)
(%modify-service service clauses ...))
--
2.6.3
next prev parent reply other threads:[~2016-03-12 11:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-07 10:58 [PATCH] doc: Clarify and consolidate modify-services documentation Chris Marusich
2016-03-11 14:15 ` Ludovic Courtès
2016-03-12 11:30 ` Chris Marusich
2016-03-12 11:38 ` Chris Marusich [this message]
2016-03-13 7:33 ` Chris Marusich
2016-03-15 14:56 ` Ludovic Courtès
2016-03-17 8:12 ` Alex Kost
2016-03-17 8:52 ` Ludovic Courtès
2016-03-18 7:42 ` Alex Kost
2016-03-18 21:11 ` Ludovic Courtès
2016-03-19 8:46 ` [PATCH] gnu: texinfo: Use version 6.1 by default Alex Kost
2016-03-19 21:02 ` Ludovic Courtès
2016-03-23 8:41 ` Alex Kost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9gchqnl.fsf@gmail.com \
--to=cmmarusich@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).