aboutsummaryrefslogtreecommitdiff
path: root/gnu
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 /gnu
parentb0b9f6e0a62852a0b4d0a86d9e8427dd7d36a714 (diff)
downloadguix-cd6f6c22fb581e5ef2aa88f5e9c14a4c54a071c3.tar.gz
guix-cd6f6c22fb581e5ef2aa88f5e9c14a4c54a071c3.zip
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 'gnu')
-rw-r--r--gnu/services.scm42
-rw-r--r--gnu/services/base.scm2
2 files changed, 44 insertions, 0 deletions
diff --git a/gnu/services.scm b/gnu/services.scm
index d0fe0ade17..818252386f 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -48,6 +48,7 @@
service-kind
service-parameters
+ modify-services
service-back-edges
fold-services
@@ -133,6 +134,47 @@
(parameters service-parameters))
+(define-syntax %modify-service
+ (syntax-rules (=>)
+ ((_ service)
+ service)
+ ((_ svc (kind param => exp ...) clauses ...)
+ (if (eq? (service-kind svc) kind)
+ (let ((param (service-parameters svc)))
+ (service (service-kind svc)
+ (begin exp ...)))
+ (%modify-service svc clauses ...)))))
+
+(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)."
+ ((_ services clauses ...)
+ (map (lambda (service)
+ (%modify-service service clauses ...))
+ services))))
;;;
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 618cef8a98..b8e8ccd5f1 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -57,6 +57,7 @@
mingetty-configuration
mingetty-configuration?
mingetty-service
+ mingetty-service-type
%nscd-default-caches
%nscd-default-configuration
@@ -74,6 +75,7 @@
guix-configuration
guix-configuration?
guix-service
+ guix-service-type
%base-services))