all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Graves via Guix-patches via <guix-patches@gnu.org>
To: 69052@debbugs.gnu.org
Cc: ngraves@ngraves.fr
Subject: [bug#69052] [PATCH v2] gnu: guix: Correct home-channels-service-type extension logic.
Date: Sun, 25 Feb 2024 07:09:14 +0100	[thread overview]
Message-ID: <20240225060917.12152-1-ngraves@ngraves.fr> (raw)
In-Reply-To: <20240211124505.15924-1-ngraves@ngraves.fr>

* gnu/home/services/guix.scm
(extend-channel-list): Add function.
(home-channels-service-type)[extend]: Use extend-channel-list.

Change-Id: I587207b86216f075a54b6ed0b8fa998896bbed74
---
 gnu/home/services/guix.scm | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gnu/home/services/guix.scm b/gnu/home/services/guix.scm
index 819b20b6c9..1b33fc2865 100644
--- a/gnu/home/services/guix.scm
+++ b/gnu/home/services/guix.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2022 Reily Siegel <mail@reilysiegel.com>
+;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,8 +23,24 @@ (define-module (gnu home services guix)
   #:use-module (guix gexp)
   #:use-module (ice-9 pretty-print)
   #:use-module (srfi srfi-1)
+  #:use-module (ice-9 match)
   #:export (home-channels-service-type))
 
+(define (channel-name-symbol channel)
+  (match (channel-name channel)
+    ((? symbol? name) name)
+    ((? string? name) (string->symbol name))))
+
+(define (extend-channel-list default new)
+  "Prepend the channels in NEW by the channels in DEFAULT if their
+channel-name is not in NEW."
+  (fold-right
+   (lambda (channel acc)
+     (if (member (channel-name channel) (map channel-name-symbol acc))
+         acc
+         (cons channel acc)))
+   new default))
+
 (define (channels-xdg-files channels)
   `(("guix/channels.scm"
      ,(plain-file
@@ -37,7 +54,7 @@ (define home-channels-service-type
    (name 'home-channels)
    (default-value %default-channels)
    (compose concatenate)
-   (extend append)
+   (extend extend-channel-list)
    (extensions
     (list (service-extension home-xdg-configuration-files-service-type
                              channels-xdg-files)))
-- 
2.41.0





  parent reply	other threads:[~2024-02-25  6:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-11 12:44 [bug#69052] [PATCH] gnu: guix: Correct home-channels-service-type extension logic Nicolas Graves via Guix-patches via
2024-02-11 17:20 ` [bug#69052] Light rework needed Nicolas Graves via Guix-patches via
2024-02-25  6:09 ` Nicolas Graves via Guix-patches via [this message]
2024-03-02 15:19   ` [bug#69052] [PATCH v2] gnu: guix: Correct home-channels-service-type extension logic Ludovic Courtès
2024-04-13 23:33 ` [bug#69052] [PATCH v3] " Nicolas Graves via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240225060917.12152-1-ngraves@ngraves.fr \
    --to=guix-patches@gnu.org \
    --cc=69052@debbugs.gnu.org \
    --cc=ngraves@ngraves.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.