Patchwork [2/2] gnu: Add GSSD and Pipefs services

login
register
mail settings
Submitter John Darrington
Date Sept. 10, 2016, 7:18 p.m.
Message ID <1473535083-5326-2-git-send-email-jmd@gnu.org>
Download mbox | patch
Permalink /patch/15494/
State New
Headers show

Comments

John Darrington - Sept. 10, 2016, 7:18 p.m.
* gnu/services/nfs.scm (pipefs-service-type): New Variable,
(gss-service-type): New Variable.
---
 doc/guix.texi        | 48 +++++++++++++++++++++++++++++++++++----
 gnu/services/nfs.scm | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 107 insertions(+), 5 deletions(-)
Ludovic Courtès - Sept. 13, 2016, 11:45 a.m.
John Darrington <jmd@gnu.org> skribis:

> * gnu/services/nfs.scm (pipefs-service-type): New Variable,
> (gss-service-type): New Variable.

Nice!  Minor comments below:

> -@node Miscellaneous Services
> -@subsubsection Miscellaneous Services
> +@node NFS Services
> +@subsubsection NFS Services

I would call it “Network File System Services” or just “Network File
System”.

> +@cindex nfs

NFS.

> +The @code{(gnu services nfs)} module provides the following services,
> +which are most commonly used in relation to mouting or exporting NFS
> +filesystems.

“… to mounting or exporting files using the @dfn{Network File System}
(NFS).”

(Always write “file system” as two words.)

> +@subsubheading GSS Daemon Service
> +@cindex gssd
> +@cindex gss
> +
> +@defvr {Scheme Variable} gss-service-type
> +A service type  for the RPC Global Security System (GSS) daemon.
                 ^^
Extra space.

Is “RPC” needed here, or is it more generic?

Would be nice to add a sentence like “The GSS daemon provides mechanism
XYZ, which can be used to implement FOOBAR.”, where FOOBAR has some
connection with NFS.  I don’t know myself what to put in here but
hopefully there’s a README or something that can shed some light.  :-)

> +@deftp {Data Type} gss-configuration
> +Data type representing the configuration of the RPC GSS Daemon service.
> +This type has the following parameters:
> +@table @asis
> +@item @code{nfs-utils} (default: @code{nfs-utils})
                                    ^^^^^
Should be @var, because here we’re talking about the value of the
‘nfs-utils’ global variable.

> +@defvr {Scheme Variable} pipefs-service-type
> +A service type for the pipefs pseudo filesystem.
                                           ^^
s/pipefs pseudo filesystem/@code{rpc_pipefs} pseudo file system/
+ “… implemented by the kernel Linux.”
+ “The @command{rpc_pipefs} allows for communication between the kernel
and the user-land NFS daemons.”

> +@deftp {Data Type} pipefs-configuration
> +Data type representing the configuration of the pipefs service.
> +There are no configurable parameters to this type.
> +@end deftp

Not necessary (see below).

> +@node Miscellaneous Services
> +@subsubsection Miscellaneous Services

Oops!

> +(define-record-type* <pipefs-configuration>
> +  pipefs-configuration make-pipefs-configuration
> +  pipefs-configuration?)

Since there’s really no configuration here, it’s not needed.

> +(define pipefs-service-type
> +  (shepherd-service-type
> +   'pipefs
> +   (lambda (config)
> +     (with-imported-modules '((gnu build file-systems)
> +                              (guix build bournish))
> +       (define pipefs-dir "/var/lib/nfs/rpc_pipefs")
> +
> +       (shepherd-service
> +        (documentation "Mount the pipefs pseudo filesystem.")
> +        (provision '(rpc-pipefs))
> +
> +        (start #~(lambda ()
> +                   (mkdir-p #$pipefs-dir)
> +                   (mount "rpc_pipefs" #$pipefs-dir "rpc_pipefs")))
> +        (stop #~(lambda (pid . args)
> +                  (umount #$pipefs-dir MNT_DETACH))))))))

You could achieve something similar by extending ‘file-system-service’,
like ‘elogind-service-type’ does.  Could you try if it works here?

In that case, the name of the Shepherd service would become
“file-system-/var/lib/nfs/rpc_pipefs”.

> +     (define pkg
> +       (gss-configuration-gss config))

s/pkg/nfs-utils/

Could you send an updated patch?

Thanks for working on it!

Ludo’.
John Darrington - Sept. 13, 2016, 1:53 p.m.
On Tue, Sep 13, 2016 at 01:45:19PM +0200, Ludovic Court??s wrote:
     John Darrington <jmd@gnu.org> skribis:

     > +@item @code{nfs-utils} (default: @code{nfs-utils})
                                         ^^^^^
     Should be @var, because here we???re talking about the value of the
     ???nfs-utils??? global variable.

I think you are mistaken here.  Quoting from the Texinfo manual:

    Use the @var command to indicate metasyntactic variables. A metasyntactic 
   variable is something that stands for another piece of text. For example, you
   should use a metasyntactic variable in the documentation of a function to 
   describe the arguments that are passed to that function.

    Do not use @var for the names of normal variables in computer programs. These
   are specific names, so @code is correct for them (@code).  For example, the 
   Emacs Lisp variable texinfo-tex-command is not a metasyntactic variable; it 
   is properly formatted using @code.

Or have I got it wrong?

J'
Ludovic Courtès - Sept. 14, 2016, 2:42 p.m.
John Darrington <john@darrington.wattle.id.au> skribis:

> On Tue, Sep 13, 2016 at 01:45:19PM +0200, Ludovic Court??s wrote:
>      John Darrington <jmd@gnu.org> skribis:
>
>      > +@item @code{nfs-utils} (default: @code{nfs-utils})
>                                          ^^^^^
>      Should be @var, because here we???re talking about the value of the
>      ???nfs-utils??? global variable.
>
> I think you are mistaken here.  Quoting from the Texinfo manual:
>
>     Use the @var command to indicate metasyntactic variables. A metasyntactic 
>    variable is something that stands for another piece of text. For example, you
>    should use a metasyntactic variable in the documentation of a function to 
>    describe the arguments that are passed to that function.
>
>     Do not use @var for the names of normal variables in computer programs. These
>    are specific names, so @code is correct for them (@code).  For example, the 
>    Emacs Lisp variable texinfo-tex-command is not a metasyntactic variable; it 
>    is properly formatted using @code.
>
> Or have I got it wrong?

Dunno, my interpretation is that ‘nfs-utils’ here denotes the value of
the ‘nfs-utils’ variable, so it “stands for another piece of text”,
which is (package (name "nfs-utils") …).

No big deal, but we should settle on a single convention and so far
we’ve used @var in such cases.

Ludo’.
John Darrington - Sept. 15, 2016, 5:06 a.m.
On Tue, Sep 13, 2016 at 01:45:19PM +0200, Ludovic Court??s wrote:
     John Darrington <jmd@gnu.org> skribis:
     
     
     > +The @code{(gnu services nfs)} module provides the following services,
     > +which are most commonly used in relation to mouting or exporting NFS
     > +filesystems.
     
     (Always write ???file system??? as two words.)


I agree that we should be consistent about this.  There are numerous examples
where we have used "filesystem" whilst others use "file system".

Shall I checkin a fix?
Ludovic Courtès - Sept. 15, 2016, 8:27 p.m.
John Darrington <john@darrington.wattle.id.au> skribis:

> On Tue, Sep 13, 2016 at 01:45:19PM +0200, Ludovic Court??s wrote:
>      John Darrington <jmd@gnu.org> skribis:
>      
>      
>      > +The @code{(gnu services nfs)} module provides the following services,
>      > +which are most commonly used in relation to mouting or exporting NFS
>      > +filesystems.
>      
>      (Always write ???file system??? as two words.)
>
>
> I agree that we should be consistent about this.  There are numerous examples
> where we have used "filesystem" whilst others use "file system".
>
> Shall I checkin a fix?

Sure.  We have to be careful not to modify it in places where it
shouldn’t, such as URLs, file names, or identifiers.

Cheers,
Ludo’.
John Darrington - Sept. 21, 2016, 6:29 p.m.
On Wed, Sep 14, 2016 at 04:42:11PM +0200, Ludovic Court??s wrote:
     John Darrington <john@darrington.wattle.id.au> skribis:
     
     > On Tue, Sep 13, 2016 at 01:45:19PM +0200, Ludovic Court??s wrote:
     >      John Darrington <jmd@gnu.org> skribis:
     >
     >      > +@item @code{nfs-utils} (default: @code{nfs-utils})
     >                                          ^^^^^
     >      Should be @var, because here we???re talking about the value of the
     >      ???nfs-utils??? global variable.
     >
     > I think you are mistaken here.  Quoting from the Texinfo manual:
     >
     >     Use the @var command to indicate metasyntactic variables. A metasyntactic 
     >    variable is something that stands for another piece of text. For example, you
     >    should use a metasyntactic variable in the documentation of a function to 
     >    describe the arguments that are passed to that function.
     >
     >     Do not use @var for the names of normal variables in computer programs. These
     >    are specific names, so @code is correct for them (@code).  For example, the 
     >    Emacs Lisp variable texinfo-tex-command is not a metasyntactic variable; it 
     >    is properly formatted using @code.
     >
     > Or have I got it wrong?
     
     Dunno, my interpretation is that ???nfs-utils??? here denotes the value of
     the ???nfs-utils??? variable, so it ???stands for another piece of text???,
     which is (package (name "nfs-utils") ???).


I don't understand what you are saying.  The text says:

  This type has the following parameters:
  @item @code{nfs-utils} (default: @code{nfs-utils})

(I think it's a little confusing that both the parameter and its default value are both called 
"nfs-utils" - but that is another issue).

The first instance of @code{nfs-utils} is the name of the parameter.  It does not stand for
something else.  That is what it is really called.  Similarly, the second instance
(default: @code{nfs-utils})  also does not stand for something else.  It is literally the default
value of the parameter.


     No big deal, but we should settle on a single convention and so far
     we???ve used @var in such cases.

Well looking at other sections I see that we have been far from consistent.  Some have used @code
and others have used @var.


Now here is an example from the manual where we have correctly used @var:

   The following command-line options are supported:

   @item --build-users-group=@var{group}
   Take users from @var{group} to run build processes 

This is correct usage of @var, because here "group" is a metasyntactical variable.  That is to say we
don't intend the user to literally type "group" --- we mean him to substitute it with whatever
group name he has chosen for his builders.

However, here is a different example:

    @example
    
    (define-public hello
      (package
        (name "hello")
        (version "2.10")
        (source (origin
                  (method url-fetch)
                  (uri (string-append "mirror://gnu/hello/hello-" version
                                      ".tar.gz"))
                  (sha256
                   (base32
                    "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
        (build-system gnu-build-system)
        (home-page "http://www.gnu.org/software/hello/")
        (license gpl3+)))
    @end example
    
    In the example above, @var{hello} is defined in a module of its own,
    @code{(gnu packages hello)}.  
    

This, as I understand it, is incorrect use of @var because "hello" does not stand
for something else.  It refers litererally to  the text "hello" and we should put it in @code
to indicate that it is a fragment of code.  It is a variable which is part of guix.

I think the passage from the Texinfo manual  which I quoted is quite clear.


But I agree that we need to be consistent.  We should be consistent both within Guix and
be consistent with other projects which use Texinfo.  If you like I can checkin a change
to fixup the current inconsistencies.

J'
Ludovic Courtès - Sept. 24, 2016, 3:03 a.m.
Hi!

John Darrington <john@darrington.wattle.id.au> skribis:

> On Wed, Sep 14, 2016 at 04:42:11PM +0200, Ludovic Court??s wrote:
>      John Darrington <john@darrington.wattle.id.au> skribis:
>      
>      > On Tue, Sep 13, 2016 at 01:45:19PM +0200, Ludovic Court??s wrote:
>      >      John Darrington <jmd@gnu.org> skribis:
>      >
>      >      > +@item @code{nfs-utils} (default: @code{nfs-utils})
>      >                                          ^^^^^
>      >      Should be @var, because here we???re talking about the value of the
>      >      ???nfs-utils??? global variable.
>      >
>      > I think you are mistaken here.  Quoting from the Texinfo manual:
>      >
>      >     Use the @var command to indicate metasyntactic variables. A metasyntactic 
>      >    variable is something that stands for another piece of text. For example, you
>      >    should use a metasyntactic variable in the documentation of a function to 
>      >    describe the arguments that are passed to that function.
>      >
>      >     Do not use @var for the names of normal variables in computer programs. These
>      >    are specific names, so @code is correct for them (@code).  For example, the 
>      >    Emacs Lisp variable texinfo-tex-command is not a metasyntactic variable; it 
>      >    is properly formatted using @code.
>      >
>      > Or have I got it wrong?
>      
>      Dunno, my interpretation is that ???nfs-utils??? here denotes the value of
>      the ???nfs-utils??? variable, so it ???stands for another piece of text???,
>      which is (package (name "nfs-utils") ???).
>
>
> I don't understand what you are saying.  The text says:
>
>   This type has the following parameters:
>   @item @code{nfs-utils} (default: @code{nfs-utils})
>
> (I think it's a little confusing that both the parameter and its default value are both called 
> "nfs-utils" - but that is another issue).
>
> The first instance of @code{nfs-utils} is the name of the parameter.  It does not stand for
> something else.  That is what it is really called.  Similarly, the second instance
> (default: @code{nfs-utils})  also does not stand for something else.  It is literally the default
> value of the parameter.

The 2nd instance means “the value of the ‘nfs-utils’ global variable.”

> Now here is an example from the manual where we have correctly used @var:
>
>    The following command-line options are supported:
>
>    @item --build-users-group=@var{group}
>    Take users from @var{group} to run build processes 
>
> This is correct usage of @var, because here "group" is a metasyntactical variable.  That is to say we
> don't intend the user to literally type "group" --- we mean him to substitute it with whatever
> group name he has chosen for his builders.

Agreed.

> However, here is a different example:
>
>     @example
>     
>     (define-public hello
>       (package
>         (name "hello")
>         (version "2.10")
>         (source (origin
>                   (method url-fetch)
>                   (uri (string-append "mirror://gnu/hello/hello-" version
>                                       ".tar.gz"))
>                   (sha256
>                    (base32
>                     "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
>         (build-system gnu-build-system)
>         (home-page "http://www.gnu.org/software/hello/")
>         (license gpl3+)))
>     @end example
>     
>     In the example above, @var{hello} is defined in a module of its own,
>     @code{(gnu packages hello)}.  
>     
>
> This, as I understand it, is incorrect use of @var because "hello" does not stand
> for something else.

Oh, I finally got it, thanks for persevering.  :-)

Regarding the pipefs patch, you can safely ignore my comment.

OK, so I think you’re right and my understanding of @var was flawed.  So
forget my initial comment.  We should eventually fix invalid uses, but
no rush here.

Thanks,
Ludo’.

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 9f57744..f812a81 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -219,6 +219,7 @@  Services
 * Database Services::           SQL databases.
 * Mail Services::               IMAP, POP3, SMTP, and all that.
 * Web Services::                Web servers.
+* NFS Services::                NFS related services.
 * Miscellaneous Services::      Other services.
 
 Defining Services
@@ -7561,6 +7562,7 @@  declaration.
 * Database Services::           SQL databases.
 * Mail Services::               IMAP, POP3, SMTP, and all that.
 * Web Services::                Web servers.
+* NFS Services::                NFS Related Serivices.
 * Miscellaneous Services::      Other services.
 @end menu
 
@@ -10091,15 +10093,49 @@  directories are created when the service is activated.
 
 @end deffn
 
-@node Miscellaneous Services
-@subsubsection Miscellaneous Services
+@node NFS Services
+@subsubsection NFS Services
+@cindex nfs
+
+The @code{(gnu services nfs)} module provides the following services,
+which are most commonly used in relation to mouting or exporting NFS
+filesystems.
+
+@subsubheading GSS Daemon Service
+@cindex gssd
+@cindex gss
+
+@defvr {Scheme Variable} gss-service-type
+A service type  for the RPC Global Security System (GSS) daemon.
+@end defvr
+
+@deftp {Data Type} gss-configuration
+Data type representing the configuration of the RPC GSS Daemon service.
+This type has the following parameters:
+@table @asis
+@item @code{nfs-utils} (default: @code{nfs-utils})
+The package in which the @command{rpc.gssd} command is to be found.
+
+@end table
+@end deftp
+
+
+@subsubheading Pipefs Pseudo Filesystem
+@cindex pipefs
+@cindex rpc_pipefs
 
+@defvr {Scheme Variable} pipefs-service-type
+A service type for the pipefs pseudo filesystem.
+@end defvr
+
+@deftp {Data Type} pipefs-configuration
+Data type representing the configuration of the pipefs service.
+There are no configurable parameters to this type.
+@end deftp
 
 @subsubheading RPC Bind Service
 @cindex rpcbind
 
-The @code{(gnu services nfs)} module provides the following:
-
 @defvr {Scheme Variable} rpcbind-service-type
 A service type  for the RPC portmapper daemon.
 @end defvr
@@ -10119,6 +10155,10 @@  instance.
 @end table
 @end deftp
 
+@node Miscellaneous Services
+@subsubsection Miscellaneous Services
+
+
 @cindex lirc
 @subsubheading Lirc Service
 
diff --git a/gnu/services/nfs.scm b/gnu/services/nfs.scm
index 82713d8..0fa613a 100644
--- a/gnu/services/nfs.scm
+++ b/gnu/services/nfs.scm
@@ -20,11 +20,22 @@ 
   #:use-module (gnu)
   #:use-module (gnu services shepherd)
   #:use-module (gnu packages onc-rpc)
+  #:use-module (gnu packages linux)
   #:use-module (guix)
   #:use-module (guix records)
+  #:use-module (ice-9 match)
+  #:use-module (gnu build file-systems)
   #:export (rpcbind-service-type
             rpcbind-configuration
-            rpcbind-configuration?))
+            rpcbind-configuration?
+
+            pipefs-service-type
+            pipefs-configuration
+            pipefs-configuration?
+
+            gss-service-type
+            gss-configuration
+            gss-configuration?))
 
 (define-record-type* <rpcbind-configuration>
   rpcbind-configuration make-rpcbind-configuration
@@ -52,3 +63,54 @@ 
 
       (start #~(make-forkexec-constructor #$rpcbind-command))
       (stop #~(make-kill-destructor))))))
+
+
+
+(define-record-type* <pipefs-configuration>
+  pipefs-configuration make-pipefs-configuration
+  pipefs-configuration?)
+
+(define pipefs-service-type
+  (shepherd-service-type
+   'pipefs
+   (lambda (config)
+     (with-imported-modules '((gnu build file-systems)
+                              (guix build bournish))
+       (define pipefs-dir "/var/lib/nfs/rpc_pipefs")
+
+       (shepherd-service
+        (documentation "Mount the pipefs pseudo filesystem.")
+        (provision '(rpc-pipefs))
+
+        (start #~(lambda ()
+                   (mkdir-p #$pipefs-dir)
+                   (mount "rpc_pipefs" #$pipefs-dir "rpc_pipefs")))
+        (stop #~(lambda (pid . args)
+                  (umount #$pipefs-dir MNT_DETACH))))))))
+
+
+
+(define-record-type* <gss-configuration>
+  gss-configuration make-gss-configuration
+  gss-configuration?
+  (nfs-utils             gss-configuration-gss
+                         (default nfs-utils)))
+
+(define gss-service-type
+  (shepherd-service-type
+   'gss
+   (lambda (config)
+     (define pkg
+       (gss-configuration-gss config))
+
+     (define gss-command
+       #~(list (string-append #$pkg "/sbin/rpc.gssd") "-f"))
+
+     (shepherd-service
+      (documentation "Start the RPC GSS daemon.")
+      (requirement '(rpcbind-daemon rpc-pipefs))
+      (provision '(gss-daemon))
+
+      (start #~(make-forkexec-constructor #$gss-command))
+      (stop #~(make-kill-destructor))))))
+