Subject: Re: [bug#45692] [PATCH 2/4] gnu: Make file-systems target extensible by services.

From: raid5atemyhomework <[email-masked]>
Date: Mon, 25 Jan 2021 00:18:12 +0000

Hello as well,

That is certainly another possibility, would this be more palatable to Guix?

Thanks
raid5atemyhomework

> Hello!
>
> raid5atemyhomework [email-masked] writes:
>
> > > From 792a8f8efc95e4fe9a94d42f839ddcfb034b8540 Mon Sep 17 00:00:00 2001
> > > From: raid5atemyhomework [email-masked]
> > > Date: Wed, 6 Jan 2021 08:15:54 +0800
> > > Subject: [PATCH 2/4] gnu: Make file-systems target extensible by services.
>
> It’s not clear to me what “file-systems target” is, and why we’re
> extending ‘file-systems-target-service-type’… I think what we want is
> to extend the ‘file-system-service-type’ with shepherd services’ names,
> which means some shepherd services that will handle file systems
> mounting themself instead of the usual <file-system> objects, fstab
> entries, mounted by kernel.
>
> So I write with this patch to extend file-system-service-type directly
> instead of introducing a new ‘file-systems-target-service-type’:
>
> What do you think? Thank you!

From 44ee1e470a2f9d4985af4d51654d9f943caa0f24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <[email-masked]>
Date: Sat, 23 Jan 2021 20:39:06 +0800
Subject: [PATCH] services: Allow 'file-system-service-type' extensible by
 service name.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* gnu/services/base.scm (file-system-shepherd-services): Add
'extra-services-names' paramater.
(file-system-service-type): Handle services’ names from extensions.
---
 gnu/services/base.scm | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index f6a490f712..7bddef5034 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -364,15 +364,16 @@ FILE-SYSTEM."
                        (gnu system file-systems)
                        ,@%default-modules)))))))
 
-(define (file-system-shepherd-services file-systems)
+(define (file-system-shepherd-services file-systems extra-services-names)
   "Return the list of Shepherd services for FILE-SYSTEMS."
   (let* ((file-systems (filter file-system-mount? file-systems)))
     (define sink
       (shepherd-service
        (provision '(file-systems))
-       (requirement (cons* 'root-file-system 'user-file-systems
-                           (map file-system->shepherd-service-name
-                                file-systems)))
+       (requirement (append '(root-file-system user-file-systems)
+                            (map file-system->shepherd-service-name
+                                 file-systems)
+                            extra-services-names))
        (documentation "Target for all the initially-mounted file systems")
        (start #~(const #t))
        (stop #~(const #f))))
@@ -429,13 +430,23 @@ FILE-SYSTEM."
   (service-type (name 'file-systems)
                 (extensions
                  (list (service-extension shepherd-root-service-type
-                                          file-system-shepherd-services)
+                                          (lambda (value)
+                                            (file-system-shepherd-services
+                                             (filter file-system? value)
+                                             (filter symbol? value))))
                        (service-extension fstab-service-type
-                                          file-system-fstab-entries)
+                                          (lambda (value)
+                                            (file-system-fstab-entries
+                                             (filter file-system? value))))
 
                        ;; Have 'user-processes' depend on 'file-systems'.
                        (service-extension user-processes-service-type
                                           (const '(file-systems)))))
+
+                ;; Extensions consist of lists of <file-system> objects or
+                ;; shepherd services’ names (symbols).  In the latter case,
+                ;; the provided shepherd services supposed to mount and
+                ;; unmount some file systems themself.
                 (compose concatenate)
                 (extend append)
                 (description
-- 
2.29.2