GNU bug report logs - #65119
[PATCH 0/8] Sharing service code between Home and System

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sun, 6 Aug 2023 21:06:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 65119 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 65119 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH 4/8] services: Define 'for-home'.
Date: Sun,  6 Aug 2023 23:07:31 +0200
* gnu/services.scm (remove-service-extensions): New procedure.
(for-home?): New syntax parameter.
(for-home): New macro.
---
 gnu/services.scm | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/gnu/services.scm b/gnu/services.scm
index 109e050a23..eb9258977e 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015-2022 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2015-2023 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2016 Chris Marusich <cmmarusich <at> gmail.com>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
 ;;; Copyright © 2020, 2021 Ricardo Wurmus <rekado <at> elephly.net>
@@ -86,6 +86,10 @@ (define-module (gnu services)
             instantiate-missing-services
             fold-services
 
+            remove-service-extensions
+            for-home
+            for-home?
+
             service-error?
             missing-value-service-error?
             missing-value-service-error-type
@@ -1225,4 +1229,23 @@ (define* (fold-services services
                            (G_ "more than one target service of type '~a'")
                            (service-type-name target-type)))))))))
 
+(define (remove-service-extensions type lst)
+  "Return TYPE, a service type, without any of the service extensions
+targeting one of the types in LST."
+  (service-type
+   (inherit type)
+   (extensions (remove (lambda (extension)
+                         (memq (service-extension-target extension) lst))
+                       (service-type-extensions type)))))
+
+(define-syntax-parameter for-home?
+  ;; Whether the configuration being defined is for a Home service.
+  (identifier-syntax #f))
+
+(define-syntax-rule (for-home exp ...)
+  "Mark EXP, which typically defines a service configuration, as targeting a
+Home service rather than a System service."
+  (syntax-parameterize ((for-home? (identifier-syntax #t)))
+    exp ...))
+
 ;;; services.scm ends here.
-- 
2.41.0





This bug report was last modified 1 year and 223 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.