services: guix: Generalize extensions.
* gnu/services/base.scm (<guix-extension>): New record type. (guix-extension-merge): New procedure. (guix-service-type): Honor extensions. * doc/guix.texi (Base Services): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
		
							parent
							
								
									8918ce6d16
								
							
						
					
					
						commit
						fcad622648
					
				
					 2 changed files with 57 additions and 6 deletions
				
			
		| 
						 | 
					@ -103,6 +103,7 @@ Copyright @copyright{} 2022 Remco van 't Veer@*
 | 
				
			||||||
Copyright @copyright{} 2022 Aleksandr Vityazev@*
 | 
					Copyright @copyright{} 2022 Aleksandr Vityazev@*
 | 
				
			||||||
Copyright @copyright{} 2022 Philip M@sup{c}Grath@*
 | 
					Copyright @copyright{} 2022 Philip M@sup{c}Grath@*
 | 
				
			||||||
Copyright @copyright{} 2022 Karl Hallsby@*
 | 
					Copyright @copyright{} 2022 Karl Hallsby@*
 | 
				
			||||||
 | 
					Copyright @copyright{} 2022 Justin Veilleux@*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Permission is granted to copy, distribute and/or modify this document
 | 
					Permission is granted to copy, distribute and/or modify this document
 | 
				
			||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
 | 
					under the terms of the GNU Free Documentation License, Version 1.3 or
 | 
				
			||||||
| 
						 | 
					@ -17729,6 +17730,25 @@ A directory path where the @command{guix-daemon} will perform builds.
 | 
				
			||||||
@end table
 | 
					@end table
 | 
				
			||||||
@end deftp
 | 
					@end deftp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@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{'()}]
 | 
					@deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
 | 
				
			||||||
Run @var{udev}, which populates the @file{/dev} directory dynamically.
 | 
					Run @var{udev}, which populates the @file{/dev} directory dynamically.
 | 
				
			||||||
udev rules can be provided as a list of files through the @var{rules}
 | 
					udev rules can be provided as a list of files through the @var{rules}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,7 @@
 | 
				
			||||||
;;; Copyright © 2021 Hui Lu <luhuins@163.com>
 | 
					;;; Copyright © 2021 Hui Lu <luhuins@163.com>
 | 
				
			||||||
;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 | 
					;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 | 
				
			||||||
;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
 | 
					;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
 | 
				
			||||||
 | 
					;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
;;; This file is part of GNU Guix.
 | 
					;;; This file is part of GNU Guix.
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
| 
						 | 
					@ -187,6 +188,12 @@
 | 
				
			||||||
            guix-configuration-extra-options
 | 
					            guix-configuration-extra-options
 | 
				
			||||||
            guix-configuration-log-file
 | 
					            guix-configuration-log-file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            guix-extension
 | 
				
			||||||
 | 
					            guix-extension?
 | 
				
			||||||
 | 
					            guix-extension-authorized-keys
 | 
				
			||||||
 | 
					            guix-extension-substitute-urls
 | 
				
			||||||
 | 
					            guix-extension-chroot-directories
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            guix-service-type
 | 
					            guix-service-type
 | 
				
			||||||
            guix-publish-configuration
 | 
					            guix-publish-configuration
 | 
				
			||||||
            guix-publish-configuration?
 | 
					            guix-publish-configuration?
 | 
				
			||||||
| 
						 | 
					@ -1768,6 +1775,25 @@ proxy of 'guix-daemon'...~%")
 | 
				
			||||||
              (substitute-key-authorization authorized-keys guix)
 | 
					              (substitute-key-authorization authorized-keys guix)
 | 
				
			||||||
              #~#f))))
 | 
					              #~#f))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(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
 | 
					(define guix-service-type
 | 
				
			||||||
  (service-type
 | 
					  (service-type
 | 
				
			||||||
   (name 'guix)
 | 
					   (name 'guix)
 | 
				
			||||||
| 
						 | 
					@ -1778,14 +1804,19 @@ proxy of 'guix-daemon'...~%")
 | 
				
			||||||
          (service-extension profile-service-type
 | 
					          (service-extension profile-service-type
 | 
				
			||||||
                             (compose list guix-configuration-guix))))
 | 
					                             (compose list guix-configuration-guix))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   ;; Extensions can specify extra directories to add to the build chroot.
 | 
					   ;; Extensions can specify extra directories to add to the build chroot,
 | 
				
			||||||
   (compose concatenate)
 | 
					   ;; extra substitute urls and extra authorized keys
 | 
				
			||||||
   (extend (lambda (config directories)
 | 
					   (compose (lambda (args) (fold guix-extension-merge (guix-extension) args)))
 | 
				
			||||||
 | 
					   (extend (lambda (config extension)
 | 
				
			||||||
             (guix-configuration
 | 
					             (guix-configuration
 | 
				
			||||||
              (inherit config)
 | 
					              (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
 | 
					              (chroot-directories
 | 
				
			||||||
               (append (guix-configuration-chroot-directories config)
 | 
					               (append (guix-extension-chroot-directories extension)
 | 
				
			||||||
                       directories)))))
 | 
					                       (guix-configuration-chroot-directories config))))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   (default-value (guix-configuration))
 | 
					   (default-value (guix-configuration))
 | 
				
			||||||
   (description
 | 
					   (description
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue