all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#69052] [PATCH] gnu: guix: Correct home-channels-service-type extension logic.
@ 2024-02-11 12:44 Nicolas Graves via Guix-patches via
  2024-02-11 17:20 ` [bug#69052] Light rework needed Nicolas Graves via Guix-patches via
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-02-11 12:44 UTC (permalink / raw)
  To: 69052; +Cc: ngraves

* 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@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





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#69052] Light rework needed
  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 ` Nicolas Graves via Guix-patches via
  2024-02-25  6:09 ` [bug#69052] [PATCH v2] gnu: guix: Correct home-channels-service-type extension logic Nicolas Graves via Guix-patches via
  2024-04-13 23:33 ` [bug#69052] [PATCH v3] " Nicolas Graves via Guix-patches via
  2 siblings, 0 replies; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-02-11 17:20 UTC (permalink / raw)
  To: 69052


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




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#69052] [PATCH v2] gnu: guix: Correct home-channels-service-type extension logic.
  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
  2024-03-02 15:19   ` Ludovic Courtès
  2024-04-13 23:33 ` [bug#69052] [PATCH v3] " Nicolas Graves via Guix-patches via
  2 siblings, 1 reply; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-02-25  6:09 UTC (permalink / raw)
  To: 69052; +Cc: ngraves

* 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





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#69052] [PATCH v2] gnu: guix: Correct home-channels-service-type extension logic.
  2024-02-25  6:09 ` [bug#69052] [PATCH v2] gnu: guix: Correct home-channels-service-type extension logic Nicolas Graves via Guix-patches via
@ 2024-03-02 15:19   ` Ludovic Courtès
  0 siblings, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2024-03-02 15:19 UTC (permalink / raw)
  To: Nicolas Graves; +Cc: 69052

Hi,

Nicolas Graves <ngraves@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’.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#69052] [PATCH v3] gnu: guix: Correct home-channels-service-type extension logic.
  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 ` [bug#69052] [PATCH v2] gnu: guix: Correct home-channels-service-type extension logic Nicolas Graves via Guix-patches via
@ 2024-04-13 23:33 ` Nicolas Graves via Guix-patches via
  2 siblings, 0 replies; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-04-13 23:33 UTC (permalink / raw)
  To: 69052; +Cc: ludo, ngraves

* 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@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





^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-13 23:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [bug#69052] [PATCH v2] gnu: guix: Correct home-channels-service-type extension logic Nicolas Graves via Guix-patches via
2024-03-02 15:19   ` Ludovic Courtès
2024-04-13 23:33 ` [bug#69052] [PATCH v3] " Nicolas Graves via Guix-patches via

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.