summaryrefslogtreecommitdiff
path: root/gnu/services.scm
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2020-05-10 23:29:38 +0200
committerRicardo Wurmus <rekado@elephly.net>2021-04-12 17:49:07 +0200
commita247f5c7537df7e0c09051ba22d5c95eb08f48b9 (patch)
tree7a7d0fb3ddb878526dea5755e16f5ee9f0c17c56 /gnu/services.scm
parentc1ed3b048d6644b70221eac2dc9b67420a999462 (diff)
services: Support DELETE in MODIFY-SERVICES macro.
* gnu/services.scm (%modify-service): Add clause for DELETE syntax. (modify-services): Use FILTER-MAP; adjust docstring. * doc/guix.texi (System Services): Mention alternative syntax. (X Window): Use MODIFY-SERVICES syntax.
Diffstat (limited to 'gnu/services.scm')
-rw-r--r--gnu/services.scm27
1 files changed, 19 insertions, 8 deletions
diff --git a/gnu/services.scm b/gnu/services.scm
index ddd1bac30c0..e7da0a026d8 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -2,6 +2,7 @@
2;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com> 3;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
4;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> 4;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
5;;; Copyright © 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
5;;; 6;;;
6;;; This file is part of GNU Guix. 7;;; This file is part of GNU Guix.
7;;; 8;;;
@@ -109,7 +110,11 @@
109 110
110 %boot-service 111 %boot-service
111 %activation-service 112 %activation-service
112 etc-service)) 113 etc-service)
114 #:re-export (;; Note: Re-export 'delete' to allow for proper syntax matching
115 ;; in 'modify-services' forms. See
116 ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26805#16>.
117 delete))
113 118
114;;; Comment: 119;;; Comment:
115;;; 120;;;
@@ -279,7 +284,11 @@ singleton service type NAME, of which the returned service is an instance."
279 (service type value))) 284 (service type value)))
280 285
281(define-syntax %modify-service 286(define-syntax %modify-service
282 (syntax-rules (=>) 287 (syntax-rules (=> delete)
288 ((_ svc (delete kind) clauses ...)
289 (if (eq? (service-kind svc) kind)
290 #f
291 (%modify-service svc clauses ...)))
283 ((_ service) 292 ((_ service)
284 service) 293 service)
285 ((_ svc (kind param => exp ...) clauses ...) 294 ((_ svc (kind param => exp ...) clauses ...)
@@ -309,16 +318,18 @@ TYPE. Consider this example:
309 (mingetty-service-type config => 318 (mingetty-service-type config =>
310 (mingetty-configuration 319 (mingetty-configuration
311 (inherit config) 320 (inherit config)
312 (motd (plain-file \"motd\" \"Hi there!\"))))) 321 (motd (plain-file \"motd\" \"Hi there!\"))))
322 (delete udev-service-type))
313 323
314It changes the configuration of the GUIX-SERVICE-TYPE instance, and that of 324It changes the configuration of the GUIX-SERVICE-TYPE instance, and that of
315all the MINGETTY-SERVICE-TYPE instances. 325all the MINGETTY-SERVICE-TYPE instances, and it deletes instances of the
326UDEV-SERVICE-TYPE.
316 327
317This is a shorthand for (map (lambda (svc) ...) %base-services)." 328This is a shorthand for (filter-map (lambda (svc) ...) %base-services)."
318 ((_ services clauses ...) 329 ((_ services clauses ...)
319 (map (lambda (service) 330 (filter-map (lambda (service)
320 (%modify-service service clauses ...)) 331 (%modify-service service clauses ...))
321 services)))) 332 services))))
322 333
323 334
324;;; 335;;;