diff mbox

gnu: Add rpc-daemon service

Message ID 1472884782-27956-1-git-send-email-jmd@gnu.org
State New
Headers show

Commit Message

John Darrington Sept. 3, 2016, 6:39 a.m. UTC
* gnu/services/nfs: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk         |  1 +
 gnu/services/nfs.scm | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 gnu/services/nfs.scm

Comments

Ludovic Courtès Sept. 3, 2016, 2:11 p.m. UTC | #1
John Darrington <jmd@gnu.org> skribis:

> * gnu/services/nfs: New file.
                   ^^
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.

For the final patch, please make sure to mention it in guix.texi.

> --- /dev/null
> +++ b/gnu/services/nfs.scm

Missing license.

> @@ -0,0 +1,25 @@
> +(define-module (gnu services nfs)
> +  #:use-module (gnu)
> +  #:use-module (gnu services shepherd)
> +  #:use-module (gnu packages onc-rpc)
> +  #:use-module (guix)
> +  #:export (rpc-service))
> +
> +(define (rpc-shepherd-service config) ; Config is ignored
> +  (list (shepherd-service
> +         (provision '(rpc-daemon))
> +         (requirement '(networking))
> +         (start #~(make-forkexec-constructor
> +                   (list (string-append #$rpcbind "/bin/rpcbind") "-d" "-f")))
> +         (stop #~(make-kill-destructor)))))
> +
> +(define rpc-service-type
> +  (service-type
> +   (name 'rpc)
> +   (extensions (list (service-extension shepherd-root-service-type
> +                                        rpc-shepherd-service)))))

In this case, you can simply write:

  (define rpcbind-service-type
    (shepherd-service-type
     'rpcbind
     (lambda (config)
       (shepherd-service …))))

I think the service should be called “rpcbind”, and not “rpc” (there are
other ONC RPC and NFS daemons, such as mountd and statd, so we need to
use clear names.)

> +(define* (rpc-service config)
> +  "Run the rpc daemon. Config is ignored."
> +  (service rpc-service-type config))

There’s at least one bit of config needed: the ‘rpcbind’ package to
use.  So I would write it as:

  (service rpcbind-service-type rpcbind)

and then honor this argument.

Also, the preferred way now is to expose service-type objects and not
provide procedures like the one above.  So you can omit this procedure
and instead make sure to #:export (rpcbind-service-type).

Could you send an updated patch?

If you’re willing to play a bit, it would be nice to have a system test
that spawns a GuixSD with this service, and then makes sure that, say,
the ‘rpcinfo’ program is able to connect to the daemon.  But that’s
bonus.  :-)

Thanks!

Ludo’.
John Darrington Sept. 3, 2016, 2:54 p.m. UTC | #2
On Sat, Sep 03, 2016 at 04:11:53PM +0200, Ludovic Courtès wrote:

will do.
     
     > --- /dev/null
     > +++ b/gnu/services/nfs.scm
     
     Missing license.

ok.

     
     Also, the preferred way now is to expose service-type objects and not
     provide procedures like the one above.  So you can omit this procedure
     and instead make sure to #:export (rpcbind-service-type).

So what do I then put in /etc/config.scm ?
When I make your suggested change, I get this error:

 ./pre-inst-env guix system reconfigure /etc/config.scm
guix system: error: failed to load '/etc/config.scm':
/etc/config.scm:60:24: In procedure #<procedure 4a4df00 ()>:
/etc/config.scm:60:24: In procedure module-lookup: Unbound variable: rpcbind-service

     
     
     If you’re willing to play a bit, it would be nice to have a system test
     that spawns a GuixSD with this service, and then makes sure that, say,
     the ‘rpcinfo’ program is able to connect to the daemon.  But that’s
     bonus.  :-)
     
Are there some examples of existing system tests?

J'
Ludovic Courtès Sept. 5, 2016, 8:38 p.m. UTC | #3
John Darrington <john@darrington.wattle.id.au> skribis:

>      Also, the preferred way now is to expose service-type objects and not
>      provide procedures like the one above.  So you can omit this procedure
>      and instead make sure to #:export (rpcbind-service-type).
>
> So what do I then put in /etc/config.scm ?

(operating-system
  ;; …
  (services (cons (service rpcbind-service-type
                           (rpcbind-configuration …))
                  %base-services)))

>      If you’re willing to play a bit, it would be nice to have a system test
>      that spawns a GuixSD with this service, and then makes sure that, say,
>      the ‘rpcinfo’ program is able to connect to the daemon.  But that’s
>      bonus.  :-)
>      
> Are there some examples of existing system tests?

Yes, in gnu/tests/*.scm.

See also <https://savannah.gnu.org/forum/forum.php?forum_id=8605> and
<https://www.gnu.org/software/guix/manual/html_node/Running-the-Test-Suite.html>.

HTH!
Ludo’.
diff mbox

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index efb00b9..8d2de1d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -388,6 +388,7 @@  GNU_SYSTEM_MODULES =				\
   %D%/services/mail.scm				\
   %D%/services/mcron.scm			\
   %D%/services/networking.scm			\
+  %D%/services/nfs.scm			\
   %D%/services/shepherd.scm			\
   %D%/services/herd.scm				\
   %D%/services/spice.scm				\
diff --git a/gnu/services/nfs.scm b/gnu/services/nfs.scm
new file mode 100644
index 0000000..2ff5a36
--- /dev/null
+++ b/gnu/services/nfs.scm
@@ -0,0 +1,25 @@ 
+(define-module (gnu services nfs)
+  #:use-module (gnu)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu packages onc-rpc)
+  #:use-module (guix)
+  #:export (rpc-service))
+
+(define (rpc-shepherd-service config) ; Config is ignored
+  (list (shepherd-service
+         (provision '(rpc-daemon))
+         (requirement '(networking))
+         (start #~(make-forkexec-constructor
+                   (list (string-append #$rpcbind "/bin/rpcbind") "-d" "-f")))
+         (stop #~(make-kill-destructor)))))
+
+(define rpc-service-type
+  (service-type
+   (name 'rpc)
+   (extensions (list (service-extension shepherd-root-service-type
+                                        rpc-shepherd-service)))))
+
+(define* (rpc-service config)
+  "Run the rpc daemon. Config is ignored."
+  (service rpc-service-type config))
+