From a247f5c7537df7e0c09051ba22d5c95eb08f48b9 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 10 May 2020 23:29:38 +0200 Subject: 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. --- gnu/services.scm | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'gnu/services.scm') diff --git a/gnu/services.scm b/gnu/services.scm index ddd1bac30c..e7da0a026d 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2020, 2021 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -109,7 +110,11 @@ %boot-service %activation-service - etc-service)) + etc-service) + #:re-export (;; Note: Re-export 'delete' to allow for proper syntax matching + ;; in 'modify-services' forms. See + ;; . + delete)) ;;; Comment: ;;; @@ -279,7 +284,11 @@ singleton service type NAME, of which the returned service is an instance." (service type value))) (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) ((_ svc (kind param => exp ...) clauses ...) @@ -309,16 +318,18 @@ TYPE. Consider this example: (mingetty-service-type config => (mingetty-configuration (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 -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 ...) - (map (lambda (service) - (%modify-service service clauses ...)) - services)))) + (filter-map (lambda (service) + (%modify-service service clauses ...)) + services)))) ;;; -- cgit v1.2.3