diff options
author | Ludovic Courtès <ludo@gnu.org> | 2015-10-28 21:36:07 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-10-28 21:58:25 +0100 |
commit | cd6f6c22fb581e5ef2aa88f5e9c14a4c54a071c3 (patch) | |
tree | 2cb4a58c45015d81b11b9c2d552920da5f111f78 /gnu/services.scm | |
parent | b0b9f6e0a62852a0b4d0a86d9e8427dd7d36a714 (diff) | |
download | patches-cd6f6c22fb581e5ef2aa88f5e9c14a4c54a071c3.tar patches-cd6f6c22fb581e5ef2aa88f5e9c14a4c54a071c3.tar.gz |
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/services.scm')
-rw-r--r-- | gnu/services.scm | 42 |
1 files changed, 42 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)))) ;;; |