From patchwork Sun Aug 1 21:02:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brice Waegeneire X-Patchwork-Id: 31683 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id ABB1427BC78; Sun, 1 Aug 2021 22:04:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 7268627BC6B for ; Sun, 1 Aug 2021 22:04:09 +0100 (BST) Received: from localhost ([::1]:51284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAIcy-0001zX-Fx for patchwork@mira.cbaines.net; Sun, 01 Aug 2021 17:04:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAIcs-0001yt-Vp for guix-patches@gnu.org; Sun, 01 Aug 2021 17:04:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mAIcs-0004mf-OI for guix-patches@gnu.org; Sun, 01 Aug 2021 17:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mAIcs-0005kB-Le for guix-patches@gnu.org; Sun, 01 Aug 2021 17:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49812] [PATCH] services: In MODIFY-SERVICES macro allow specifying a service by its name. Resent-From: Brice Waegeneire Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 01 Aug 2021 21:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49812@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162785178621979 (code B ref -1); Sun, 01 Aug 2021 21:04:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 Aug 2021 21:03:06 +0000 Received: from localhost ([127.0.0.1]:37024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mAIby-0005iR-4Y for submit@debbugs.gnu.org; Sun, 01 Aug 2021 17:03:06 -0400 Received: from lists.gnu.org ([209.51.188.17]:38750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mAIbw-0005iK-FJ for submit@debbugs.gnu.org; Sun, 01 Aug 2021 17:03:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAIbv-0001vh-1B for guix-patches@gnu.org; Sun, 01 Aug 2021 17:03:04 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:46805) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAIbs-00049O-Tk for guix-patches@gnu.org; Sun, 01 Aug 2021 17:03:02 -0400 Received: (Authenticated sender: brice@waegenei.re) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id E261C20003 for ; Sun, 1 Aug 2021 21:02:57 +0000 (UTC) From: Brice Waegeneire Date: Sun, 1 Aug 2021 23:02:54 +0200 Message-Id: <20210801210254.6119-1-brice@waegenei.re> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Received-SPF: pass client-ip=217.70.183.200; envelope-from=brice@waegenei.re; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This is specially useful with any services singleton created with 'simple-service' such as 'set-xorg-configuration'. * doc/guix.texi (Service Reference)[modify-services]: Document support for specifying service by its name. * gnu/services.scm (modify-services): Support specifying a service by its name in addition to its type. --- doc/guix.texi | 14 +++++++------- gnu/services.scm | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 2298d512a1..3b50976358 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -34319,20 +34319,20 @@ standard list combinators such as @code{map} and @code{fold} to do that common pattern. @deffn {Scheme Syntax} modify-services @var{services} @ - (@var{type} @var{variable} => @var{body}) @dots{} + (@var{type-or-name} @var{variable} => @var{body}) @dots{} Modify the services listed in @var{services} according to the given clauses. Each clause has the form: @example -(@var{type} @var{variable} => @var{body}) +(@var{type-or-name} @var{variable} => @var{body}) @end example -where @var{type} is a service type---e.g., -@code{guix-service-type}---and @var{variable} is an identifier that is -bound within the @var{body} to the service parameters---e.g., a -@code{guix-configuration} instance---of the original service of that -@var{type}. +where @var{type-or-name} is a service type or name---e.g., +@code{guix-service-type} or @code{'guix}---and @var{variable} is an +identifier that is bound within the @var{body} to the service +parameters---e.g., a @code{guix-configuration} instance---of the +original service of that type. The @var{body} should evaluate to the new service parameters, which will be used to configure the new service. This new service will replace the diff --git a/gnu/services.scm b/gnu/services.scm index 2a8114a219..736ad2e4b9 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -303,8 +303,9 @@ singleton service type NAME, of which the returned service is an instance." (%modify-service svc clauses ...))) ((_ service) service) - ((_ svc (kind param => exp ...) clauses ...) - (if (eq? (service-kind svc) kind) + ((_ svc (kind-or-name param => exp ...) clauses ...) + (if (or (eq? (service-kind svc) kind-or-name) ;kind + (eq? (service-type-name (service-kind svc)) kind-or-name)) ;name (let ((param (service-value svc))) (service (service-kind svc) (begin exp ...)))