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.
This commit is contained in:
		
							parent
							
								
									c1ed3b048d
								
							
						
					
					
						commit
						a247f5c753
					
				
					 2 changed files with 29 additions and 11 deletions
				
			
		| 
						 | 
					@ -13518,6 +13518,14 @@ following expression returns a list that contains all the services in
 | 
				
			||||||
        %desktop-services)
 | 
					        %desktop-services)
 | 
				
			||||||
@end lisp
 | 
					@end lisp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Alternatively, the @code{modify-services} macro can be used:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@lisp
 | 
				
			||||||
 | 
					(modify-services %desktop-services
 | 
				
			||||||
 | 
					  (delete avahi-service-type))
 | 
				
			||||||
 | 
					@end lisp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@unnumberedsubsec Instantiating the System
 | 
					@unnumberedsubsec Instantiating the System
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Assuming the @code{operating-system} declaration
 | 
					Assuming the @code{operating-system} declaration
 | 
				
			||||||
| 
						 | 
					@ -17787,9 +17795,8 @@ and tty8.
 | 
				
			||||||
                   (service slim-service-type (slim-configuration
 | 
					                   (service slim-service-type (slim-configuration
 | 
				
			||||||
                                               (display ":1")
 | 
					                                               (display ":1")
 | 
				
			||||||
                                               (vt "vt8")))
 | 
					                                               (vt "vt8")))
 | 
				
			||||||
                   (remove (lambda (service)
 | 
					                   (modify-services %desktop-services
 | 
				
			||||||
                             (eq? (service-kind service) gdm-service-type))
 | 
					                     (delete gdm-service-type)))))
 | 
				
			||||||
                           %desktop-services))))
 | 
					 | 
				
			||||||
@end lisp
 | 
					@end lisp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@end defvr
 | 
					@end defvr
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 | 
					;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 | 
				
			||||||
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
 | 
					;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
 | 
				
			||||||
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 | 
					;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 | 
				
			||||||
 | 
					;;; Copyright © 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
;;; This file is part of GNU Guix.
 | 
					;;; This file is part of GNU Guix.
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
| 
						 | 
					@ -109,7 +110,11 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            %boot-service
 | 
					            %boot-service
 | 
				
			||||||
            %activation-service
 | 
					            %activation-service
 | 
				
			||||||
            etc-service))
 | 
					            etc-service)
 | 
				
			||||||
 | 
					  #:re-export (;; Note: Re-export 'delete' to allow for proper syntax matching
 | 
				
			||||||
 | 
					               ;; in 'modify-services' forms.  See
 | 
				
			||||||
 | 
					               ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26805#16>.
 | 
				
			||||||
 | 
					               delete))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
;;; Comment:
 | 
					;;; Comment:
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
| 
						 | 
					@ -279,7 +284,11 @@ singleton service type NAME, of which the returned service is an instance."
 | 
				
			||||||
    (service type value)))
 | 
					    (service type value)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define-syntax %modify-service
 | 
					(define-syntax %modify-service
 | 
				
			||||||
  (syntax-rules (=>)
 | 
					  (syntax-rules (=> delete)
 | 
				
			||||||
 | 
					    ((_ svc (delete kind) clauses ...)
 | 
				
			||||||
 | 
					     (if (eq? (service-kind svc) kind)
 | 
				
			||||||
 | 
					         #f
 | 
				
			||||||
 | 
					         (%modify-service svc clauses ...)))
 | 
				
			||||||
    ((_ service)
 | 
					    ((_ service)
 | 
				
			||||||
     service)
 | 
					     service)
 | 
				
			||||||
    ((_ svc (kind param => exp ...) clauses ...)
 | 
					    ((_ svc (kind param => exp ...) clauses ...)
 | 
				
			||||||
| 
						 | 
					@ -309,16 +318,18 @@ TYPE.  Consider this example:
 | 
				
			||||||
    (mingetty-service-type config =>
 | 
					    (mingetty-service-type config =>
 | 
				
			||||||
                           (mingetty-configuration
 | 
					                           (mingetty-configuration
 | 
				
			||||||
                            (inherit config)
 | 
					                            (inherit config)
 | 
				
			||||||
                            (motd (plain-file \"motd\" \"Hi there!\")))))
 | 
					                            (motd (plain-file \"motd\" \"Hi there!\"))))
 | 
				
			||||||
 | 
					    (delete udev-service-type))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
It changes the configuration of the GUIX-SERVICE-TYPE instance, and that of
 | 
					It changes the configuration of the GUIX-SERVICE-TYPE instance, and that of
 | 
				
			||||||
all the MINGETTY-SERVICE-TYPE instances.
 | 
					all the MINGETTY-SERVICE-TYPE instances, and it deletes instances of the
 | 
				
			||||||
 | 
					UDEV-SERVICE-TYPE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This is a shorthand for (map (lambda (svc) ...) %base-services)."
 | 
					This is a shorthand for (filter-map (lambda (svc) ...) %base-services)."
 | 
				
			||||||
    ((_ services clauses ...)
 | 
					    ((_ services clauses ...)
 | 
				
			||||||
     (map (lambda (service)
 | 
					     (filter-map (lambda (service)
 | 
				
			||||||
            (%modify-service service clauses ...))
 | 
					                   (%modify-service service clauses ...))
 | 
				
			||||||
          services))))
 | 
					                 services))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue