all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#54918] [WIP] make guix-service-type more extendable
@ 2022-04-13 18:54 Justin Veilleux
  2022-04-30 14:18 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Justin Veilleux @ 2022-04-13 18:54 UTC (permalink / raw)
  To: 54918

[-- Attachment #1: Type: text/plain, Size: 549 bytes --]

I noticed that the extension mechanism for guix-service-type don't 
expose authorized keys and substitute-urls. I want to create a service 
to easily set up new channels with their associated substitutes server, 
but I have to go through modify-services.

I realize that this change isn't trivial as it breaks some people's 
os.scm and requires updating the documentation, but I think it is a very 
low hanging fruit in terms of functionality.

Maybe there is a reason why things are the way they are, I would greatly 
appreciate comments.

Cheers.

[-- Attachment #2: 0001-first-commit.patch --]
[-- Type: text/x-patch, Size: 4577 bytes --]

From 229ccde84a2183d31860c9616820763ddf2ac5f1 Mon Sep 17 00:00:00 2001
From: terramorpha <terramorpha@cock.li>
Date: Mon, 11 Apr 2022 00:30:07 -0400
Subject: [PATCH] first commit

---
 gnu/services/base.scm | 50 ++++++++++++++++++++++++++++++++++---------
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 5d7c69a9cd..5d779eec1a 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Hui Lu <luhuins@163.com>
 ;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -187,6 +188,12 @@ (define-module (gnu services base)
             guix-configuration-extra-options
             guix-configuration-log-file
 
+            guix-extension
+            guix-extension?
+            guix-extension-authorized-keys
+            guix-extension-substitute-urls
+            guix-extension-chroot-directories
+
             guix-service-type
             guix-publish-configuration
             guix-publish-configuration?
@@ -1788,6 +1795,25 @@ (define* (references-file item #:optional (name "references"))
                                  #:references-graphs (("graph" ,item))))
       (plain-file name "()")))
 
+(define-record-type* <guix-extension>
+  guix-extension make-guix-extension
+  guix-extension?
+  (authorized-keys guix-extension-authorized-keys ;list of gexps
+                    (default '()))
+  (substitute-urls guix-extension-substitute-urls ;list of strings
+                    (default '()))
+  (chroot-directories guix-extension-chroot-directories ;list of file-like/strings
+                      (default '())))
+
+(define (guix-extension-merge a b)
+  (guix-extension
+   (authorized-keys (append (guix-extension-authorized-keys a)
+                            (guix-extension-authorized-keys b)))
+   (substitute-urls (append (guix-extension-substitute-urls a)
+                            (guix-extension-substitute-urls b)))
+   (chroot-directories (append (guix-extension-chroot-directories a)
+                               (guix-extension-chroot-directories b)))))
+
 (define guix-service-type
   (service-type
    (name 'guix)
@@ -1798,30 +1824,34 @@ (define guix-service-type
           (service-extension profile-service-type
                              (compose list guix-configuration-guix))))
 
-   ;; Extensions can specify extra directories to add to the build chroot.
-   (compose concatenate)
-   (extend (lambda (config directories)
+   ;; Extensions can specify extra directories to add to the build chroot,
+   ;; extra substitute urls and extra authorized keys
+   (compose (lambda (args) (fold guix-extension-merge (guix-extension) args)))
+   (extend (lambda (config extension)
              (guix-configuration
               (inherit config)
+              (authorized-keys (append (guix-extension-authorized-keys extension)
+                                       (guix-configuration-authorized-keys config)))
+              (substitute-urls (append (guix-extension-substitute-urls extension)
+                                       (guix-configuration-substitute-urls config)))
               (chroot-directories
-               (append (guix-configuration-chroot-directories config)
-                       directories)))))
+               (append (guix-extension-chroot-directories extension)
+                       (guix-configuration-chroot-directories config))))))
 
    (default-value (guix-configuration))
    (description
     "Run the build daemon of GNU@tie{}Guix, aka. @command{guix-daemon}.")))
 
-
 (define-record-type* <guix-publish-configuration>
   guix-publish-configuration make-guix-publish-configuration
   guix-publish-configuration?
-  (guix    guix-publish-configuration-guix        ;file-like
+  (guix    guix-publish-configuration-guix ;file-like
            (default guix))
-  (port    guix-publish-configuration-port        ;number
+  (port    guix-publish-configuration-port ;number
            (default 80))
-  (host    guix-publish-configuration-host        ;string
+  (host    guix-publish-configuration-host ;string
            (default "localhost"))
-  (advertise? guix-publish-advertise?       ;boolean
+  (advertise? guix-publish-advertise?   ;boolean
               (default #f))
   (compression       guix-publish-configuration-compression
                      (thunked)
-- 
2.34.0


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

* [bug#54918] [WIP] make guix-service-type more extendable
  2022-04-13 18:54 [bug#54918] [WIP] make guix-service-type more extendable Justin Veilleux
@ 2022-04-30 14:18 ` Ludovic Courtès
  2022-05-01 15:35   ` Justin Veilleux
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2022-04-30 14:18 UTC (permalink / raw)
  To: Justin Veilleux; +Cc: 54918

Hi Justin,

Justin Veilleux <terramorpha@cock.li> skribis:

> I realize that this change isn't trivial as it breaks some people's
> os.scm and requires updating the documentation, but I think it is a
> very low hanging fruit in terms of functionality.

I think the risk of breakage is low: the previous extension mechanism
had only one use case, qemu-binfmt.  That use case is now gone, so we
should be fine.

> +(define-record-type* <guix-extension>
> +  guix-extension make-guix-extension
> +  guix-extension?
> +  (authorized-keys guix-extension-authorized-keys ;list of gexps
> +                    (default '()))
> +  (substitute-urls guix-extension-substitute-urls ;list of strings
> +                    (default '()))
> +  (chroot-directories guix-extension-chroot-directories ;list of file-like/strings
> +                      (default '())))

I like this approach!

Together with update documentation and a changelog, it LGTM.  Could you
send an updated patch?

Thanks,
Ludo’.




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

* [bug#54918] [WIP] make guix-service-type more extendable
  2022-04-30 14:18 ` Ludovic Courtès
@ 2022-05-01 15:35   ` Justin Veilleux
  2022-06-13 10:32     ` bug#54918: " Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Justin Veilleux @ 2022-05-01 15:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 54918

[-- Attachment #1: Type: text/plain, Size: 224 bytes --]

Hi, I updated the documentation (to the best of my abilities, I've never 
written texinfo).

For the changelog, I'm not familiar with the format for bigger changes, 
could you point me to the relevant documentation?

Cheers

[-- Attachment #2: 0001-commit-message.patch --]
[-- Type: text/x-patch, Size: 6223 bytes --]

From 314f6f1c8cb1057e6880f1776d096a615c2c5a30 Mon Sep 17 00:00:00 2001
From: terramorpha <terramorpha@cock.li>
Date: Mon, 11 Apr 2022 00:30:07 -0400
Subject: [PATCH] commit message

---
 doc/guix.texi         | 21 ++++++++++++++++++
 gnu/services/base.scm | 50 ++++++++++++++++++++++++++++++++++---------
 2 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 54793c9648..910183a8d2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -102,6 +102,7 @@ Copyright @copyright{} 2021 Sarah Morgensen@*
 Copyright @copyright{} 2021 Josselin Poiret@*
 Copyright @copyright{} 2022 Remco van 't Veer@*
 Copyright @copyright{} 2022 Aleksandr Vityazev@*
+Copyright @copyright{} 2022 Justin Veilleux@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -17147,6 +17148,26 @@ A directory path where the @command{guix-daemon} will perform builds.
 @end table
 @end deftp
 
+@anchor{guix-extension-type}
+@deftp {Data Type} guix-extension
+
+This data type represents the parameters of the Guix build daemon that
+are extendable. This is the type of the object that must be used within
+a guix service extension.
+@xref{Service Composition}, for more information.
+
+@table @asis
+@item @code{authorized-keys} (default: @code{'()})
+A list of file-like objects where each element contains a public key.
+
+@item @code{substitute-urls} (default: @code{'()})
+A list of strings where each element is a substitute URL.
+
+@item @code{chroot-directories} (default: @code{'()})
+A list of file-like objects or strings pointing to additional directories the build daemon can use.
+@end table
+@end deftp
+
 @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
 Run @var{udev}, which populates the @file{/dev} directory dynamically.
 udev rules can be provided as a list of files through the @var{rules}
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 5d7c69a9cd..fc799cb806 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Hui Lu <luhuins@163.com>
 ;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -187,6 +188,12 @@ (define-module (gnu services base)
             guix-configuration-extra-options
             guix-configuration-log-file
 
+            guix-extension
+            guix-extension?
+            guix-extension-authorized-keys
+            guix-extension-substitute-urls
+            guix-extension-chroot-directories
+
             guix-service-type
             guix-publish-configuration
             guix-publish-configuration?
@@ -1788,6 +1795,25 @@ (define* (references-file item #:optional (name "references"))
                                  #:references-graphs (("graph" ,item))))
       (plain-file name "()")))
 
+(define-record-type* <guix-extension>
+  guix-extension make-guix-extension
+  guix-extension?
+  (authorized-keys guix-extension-authorized-keys ;list of file-like
+                    (default '()))
+  (substitute-urls guix-extension-substitute-urls ;list of strings
+                    (default '()))
+  (chroot-directories guix-extension-chroot-directories ;list of file-like/strings
+                      (default '())))
+
+(define (guix-extension-merge a b)
+  (guix-extension
+   (authorized-keys (append (guix-extension-authorized-keys a)
+                            (guix-extension-authorized-keys b)))
+   (substitute-urls (append (guix-extension-substitute-urls a)
+                            (guix-extension-substitute-urls b)))
+   (chroot-directories (append (guix-extension-chroot-directories a)
+                               (guix-extension-chroot-directories b)))))
+
 (define guix-service-type
   (service-type
    (name 'guix)
@@ -1798,30 +1824,34 @@ (define guix-service-type
           (service-extension profile-service-type
                              (compose list guix-configuration-guix))))
 
-   ;; Extensions can specify extra directories to add to the build chroot.
-   (compose concatenate)
-   (extend (lambda (config directories)
+   ;; Extensions can specify extra directories to add to the build chroot,
+   ;; extra substitute urls and extra authorized keys
+   (compose (lambda (args) (fold guix-extension-merge (guix-extension) args)))
+   (extend (lambda (config extension)
              (guix-configuration
               (inherit config)
+              (authorized-keys (append (guix-extension-authorized-keys extension)
+                                       (guix-configuration-authorized-keys config)))
+              (substitute-urls (append (guix-extension-substitute-urls extension)
+                                       (guix-configuration-substitute-urls config)))
               (chroot-directories
-               (append (guix-configuration-chroot-directories config)
-                       directories)))))
+               (append (guix-extension-chroot-directories extension)
+                       (guix-configuration-chroot-directories config))))))
 
    (default-value (guix-configuration))
    (description
     "Run the build daemon of GNU@tie{}Guix, aka. @command{guix-daemon}.")))
 
-
 (define-record-type* <guix-publish-configuration>
   guix-publish-configuration make-guix-publish-configuration
   guix-publish-configuration?
-  (guix    guix-publish-configuration-guix        ;file-like
+  (guix    guix-publish-configuration-guix ;file-like
            (default guix))
-  (port    guix-publish-configuration-port        ;number
+  (port    guix-publish-configuration-port ;number
            (default 80))
-  (host    guix-publish-configuration-host        ;string
+  (host    guix-publish-configuration-host ;string
            (default "localhost"))
-  (advertise? guix-publish-advertise?       ;boolean
+  (advertise? guix-publish-advertise?   ;boolean
               (default #f))
   (compression       guix-publish-configuration-compression
                      (thunked)
-- 
2.34.0


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

* bug#54918: [WIP] make guix-service-type more extendable
  2022-05-01 15:35   ` Justin Veilleux
@ 2022-06-13 10:32     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2022-06-13 10:32 UTC (permalink / raw)
  To: Justin Veilleux; +Cc: 54918-done

Hi Justin,

Justin Veilleux <terramorpha@cock.li> skribis:

> From 314f6f1c8cb1057e6880f1776d096a615c2c5a30 Mon Sep 17 00:00:00 2001
> From: terramorpha <terramorpha@cock.li>
> Date: Mon, 11 Apr 2022 00:30:07 -0400
> Subject: [PATCH] commit message
>
> ---
>  doc/guix.texi         | 21 ++++++++++++++++++
>  gnu/services/base.scm | 50 ++++++++++++++++++++++++++++++++++---------
>  2 files changed, 61 insertions(+), 10 deletions(-)

Sorry for the looong delay.  I added a commit log and pushed as
fcad6226486b52e5d45531f60811d35eac34fa67.

Thanks!

Ludo’.




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

end of thread, other threads:[~2022-06-13 10:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13 18:54 [bug#54918] [WIP] make guix-service-type more extendable Justin Veilleux
2022-04-30 14:18 ` Ludovic Courtès
2022-05-01 15:35   ` Justin Veilleux
2022-06-13 10:32     ` bug#54918: " Ludovic Courtès

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.