GNU bug report logs - #69052
[PATCH] gnu: guix: Correct home-channels-service-type extension logic.

Previous Next

Package: guix-patches;

Reported by: Nicolas Graves <ngraves <at> ngraves.fr>

Date: Sun, 11 Feb 2024 13:42:02 UTC

Severity: normal

Tags: moreinfo, patch

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 69052 in the body.
You can then email your comments to 69052 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#69052; Package guix-patches. (Sun, 11 Feb 2024 13:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nicolas Graves <ngraves <at> ngraves.fr>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 11 Feb 2024 13:42:02 GMT) Full text and rfc822 format available.

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

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: guix-patches <at> gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH] gnu: guix: Correct home-channels-service-type extension logic.
Date: Sun, 11 Feb 2024 13:44:22 +0100
* 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 | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gnu/home/services/guix.scm b/gnu/home/services/guix.scm
index 819b20b6c9..3702976496 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 <at> reilysiegel.com>
+;;; Copyright © 2024 Nicolas Graves <ngraves <at> ngraves.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,6 +25,16 @@ (define-module (gnu home services guix)
   #:use-module (srfi srfi-1)
   #:export (home-channels-service-type))
 
+(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 acc))
+         acc
+         (cons channel acc)))
+   new default))
+
 (define (channels-xdg-files channels)
   `(("guix/channels.scm"
      ,(plain-file
@@ -37,7 +48,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





Information forwarded to guix-patches <at> gnu.org:
bug#69052; Package guix-patches. (Sun, 11 Feb 2024 17:29:01 GMT) Full text and rfc822 format available.

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

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 69052 <at> debbugs.gnu.org
Subject: Light rework needed
Date: Sun, 11 Feb 2024 18:20:41 +0100
If that's not straightforward: this patch allows the service to accept
an additional guix channel which replaces the default in this
case. Currently the default was to append, thus you could not use
another guix channel (a local guix for instance).

I've seen that a light rework is necessary. This is due to the fact that
a channel name can be both a symbol and a string, we thus need to ensure
that the (member ...) comparison is properly done if the user uses
strings instead of symbols in channel definition. 

-- 
Best regards,
Nicolas Graves




Information forwarded to guix-patches <at> gnu.org:
bug#69052; Package guix-patches. (Sun, 25 Feb 2024 06:18:02 GMT) Full text and rfc822 format available.

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

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 69052 <at> debbugs.gnu.org
Cc: ngraves <at> ngraves.fr
Subject: [PATCH v2] gnu: guix: Correct home-channels-service-type extension
 logic.
Date: Sun, 25 Feb 2024 07:09:14 +0100
* 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 <at> reilysiegel.com>
+;;; Copyright © 2024 Nicolas Graves <ngraves <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#69052; Package guix-patches. (Sat, 02 Mar 2024 15:21:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Nicolas Graves <ngraves <at> ngraves.fr>
Cc: 69052 <at> debbugs.gnu.org
Subject: Re: [bug#69052] [PATCH v2] gnu: guix: Correct
 home-channels-service-type extension logic.
Date: Sat, 02 Mar 2024 16:19:51 +0100
Hi,

Nicolas Graves <ngraves <at> ngraves.fr> skribis:

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

[...]

> +(define (channel-name-symbol channel)
> +  (match (channel-name channel)
> +    ((? symbol? name) name)
> +    ((? string? name) (string->symbol name))))

‘channel-name’ always returns a symbol so this procedure can be removed.

> +(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))

[...]

> +   (extend extend-channel-list)

I believe it’s equivalent to:

  (define (extend-channel-list initial new)
    (delete-duplicates
     (append initial new)
     (lambda (channel1 channel2)
       (eq? (channel-name channel1) (channel-name channel2)))))

… which is somewhat clearer IMO.

Could you send an updated patch?

Ludo’.




Added tag(s) moreinfo. Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 29 Mar 2024 22:17:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#69052; Package guix-patches. (Sat, 13 Apr 2024 23:34:02 GMT) Full text and rfc822 format available.

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

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 69052 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, ngraves <at> ngraves.fr
Subject: [PATCH v3] gnu: guix: Correct home-channels-service-type extension
 logic.
Date: Sun, 14 Apr 2024 01:33:04 +0200
* 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 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gnu/home/services/guix.scm b/gnu/home/services/guix.scm
index 819b20b6c9..d31d3126bb 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 <at> reilysiegel.com>
+;;; Copyright © 2024 Nicolas Graves <ngraves <at> ngraves.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,6 +25,12 @@ (define-module (gnu home services guix)
   #:use-module (srfi srfi-1)
   #:export (home-channels-service-type))
 
+(define (extend-channel-list initial new)
+  (delete-duplicates
+   (append initial new)
+   (lambda (channel1 channel2)
+     (eq? (channel-name channel1) (channel-name channel2)))))
+
 (define (channels-xdg-files channels)
   `(("guix/channels.scm"
      ,(plain-file
@@ -37,7 +44,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





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 04 Sep 2024 13:38:01 GMT) Full text and rfc822 format available.

Notification sent to Nicolas Graves <ngraves <at> ngraves.fr>:
bug acknowledged by developer. (Wed, 04 Sep 2024 13:38:02 GMT) Full text and rfc822 format available.

Message #24 received at 69052-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Nicolas Graves <ngraves <at> ngraves.fr>
Cc: 69052-done <at> debbugs.gnu.org
Subject: Re: [bug#69052] [PATCH v3] gnu: guix: Correct
 home-channels-service-type extension logic.
Date: Wed, 04 Sep 2024 15:35:51 +0200
Nicolas Graves <ngraves <at> ngraves.fr> skribis:

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

Finally applied, thanks!

Ludo'.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 03 Oct 2024 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 320 days ago.

Previous Next


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