[PATCH] gnu: guix: Correct home-channels-service-type extension logic.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Nicolas Graves
Owner
unassigned
Submitted by
Nicolas Graves
Severity
normal

Debbugs page

N
N
Nicolas Graves wrote on 11 Feb 04:44 -0800
(address . guix-patches@gnu.org)(address . ngraves@ngraves.fr)
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 | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

Toggle diff (39 lines)
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@reilysiegel.com>
+;;; Copyright © 2024 Nicolas Graves <ngraves@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
N
N
Nicolas Graves wrote on 11 Feb 09:20 -0800
Light rework needed
(address . 69052@debbugs.gnu.org)
87a5o6hq8m.fsf@ngraves.fr
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
N
N
Nicolas Graves wrote on 24 Feb 22:09 -0800
[PATCH v2] gnu: guix: Correct home-channels-service-type extension logic.
(address . 69052@debbugs.gnu.org)(address . ngraves@ngraves.fr)
20240225060917.12152-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(-)

Toggle diff (47 lines)
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
L
L
Ludovic Courtès wrote on 2 Mar 07:19 -0800
(name . Nicolas Graves)(address . ngraves@ngraves.fr)(address . 69052@debbugs.gnu.org)
87a5ngek4o.fsf@gnu.org
Hi,

Nicolas Graves <ngraves@ngraves.fr> skribis:

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

[...]

Toggle quote (5 lines)
> +(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.

Toggle quote (10 lines)
> +(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))

[...]

Toggle quote (2 lines)
> + (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’.
L
L
Ludovic Courtès wrote on 29 Mar 15:16 -0700
control message for bug #69052
(address . control@debbugs.gnu.org)
87v854fzv3.fsf@gnu.org
tags 69052 + moreinfo
quit
N
N
Nicolas Graves wrote on 13 Apr 16:33 -0700
[PATCH v3] gnu: guix: Correct home-channels-service-type extension logic.
(address . 69052@debbugs.gnu.org)
20240413233315.14875-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 | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

Toggle diff (35 lines)
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@reilysiegel.com>
+;;; Copyright © 2024 Nicolas Graves <ngraves@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
L
L
Ludovic Courtès wrote on 4 Sep 06:35 -0700
(name . Nicolas Graves)(address . ngraves@ngraves.fr)(address . 69052-done@debbugs.gnu.org)
87frqfee2w.fsf@gnu.org
Nicolas Graves <ngraves@ngraves.fr> skribis:

Toggle quote (6 lines)
> * 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'.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 69052@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 69052
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch