summaryrefslogtreecommitdiff
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
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.
-rw-r--r--doc/guix.texi13
-rw-r--r--gnu/services.scm27
2 files changed, 29 insertions, 11 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index bb86195a25e..22b4c6a6b74 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13518,6 +13518,14 @@ following expression returns a list that contains all the services in
13518 %desktop-services) 13518 %desktop-services)
13519@end lisp 13519@end lisp
13520 13520
13521Alternatively, the @code{modify-services} macro can be used:
13522
13523@lisp
13524(modify-services %desktop-services
13525 (delete avahi-service-type))
13526@end lisp
13527
13528
13521@unnumberedsubsec Instantiating the System 13529@unnumberedsubsec Instantiating the System
13522 13530
13523Assuming the @code{operating-system} declaration 13531Assuming the @code{operating-system} declaration
@@ -17787,9 +17795,8 @@ and tty8.
17787 (service slim-service-type (slim-configuration 17795 (service slim-service-type (slim-configuration
17788 (display ":1") 17796 (display ":1")
17789 (vt "vt8"))) 17797 (vt "vt8")))
17790 (remove (lambda (service) 17798 (modify-services %desktop-services
17791 (eq? (service-kind service) gdm-service-type)) 17799 (delete gdm-service-type)))))
17792 %desktop-services))))
17793@end lisp 17800@end lisp
17794 17801
17795@end defvr 17802@end defvr
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;;;