Re: [PATCH] gnu: Add Prosody service.

2017-01-08 Thread Clément Lassieur
> I would suggest moving the gnu/packages change to a separate patch, but
> apart from that I don’t have anything to add to Hartmut’s comment.
>
> Could you send updated patches?

Here they are.

> I suppose you confirmed with ‘guix system vm’ or similar that it works
> as intended.  Could you consider writing a system test for Prosody?  The
> (gnu tests mail) and (gnu tests ssh) modules provide relatively simple
> examples to start from.

It works on my GuixSD server.  I'll start to write a system test.

Thank you all for the review!



Re: [PATCH] gnu: Add Prosody service.

2017-01-07 Thread Clément Lassieur
>> Am 04.01.2017 um 22:55 schrieb Clément Lassieur:
>
>>> +;;; Commentary:
>>> +;;;
>>> +;;; Messaging services.
>>> +;;;
>>> +;;; Code:
>> […]
>>> +;;; messaging.scm ends here
>>
>> I'd leave this comment away. It is of now use. We had a loner discussion
>> about this here on the list in autum.
>
> ... which came to no real result, so these end comments are
> perfectly fine and up to the person who contributes the file
> first. So Clément, decide wether you want it or not.

I'll remove it then.



Re: [PATCH] gnu: Add Prosody service.

2017-01-07 Thread Ludovic Courtès
Hi Clément,

Clément Lassieur  skribis:

> * gnu/services/messaging.scm: New file.
> * gnu/services/configuration.scm: New exported procedures.
> * gnu/packages/messaging.scm (prosody)[arguments]: Add 'fix-makefile'
>   phase.
>   In 'wrap-programs' phase, add 'openssl' and 'coreutils' to 'PATH'.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add gnu/services/messaging.scm.
> * doc/guix.texi (Messaging Services): New section.

Great work!

I would suggest moving the gnu/packages change to a separate patch, but
apart from that I don’t have anything to add to Hartmut’s comment.

Could you send updated patches?

I suppose you confirmed with ‘guix system vm’ or similar that it works
as intended.  Could you consider writing a system test for Prosody?  The
(gnu tests mail) and (gnu tests ssh) modules provide relatively simple
examples to start from.

Thank you!

Ludo’.



Re: [PATCH] gnu: Add Prosody service.

2017-01-07 Thread Clément Lassieur
> Am 04.01.2017 um 22:55 schrieb Clément Lassieur:
>> +(define %default-modules-enabled
>> +  '("roster"
>> +"saslauth"
>> +"tls"
>> +"dialback"
>> +"disco"
>> +"private"
>> +"vcard"
>> +"version"
>> +"uptime"
>> +"time"
>> +"ping"
>> +"pep"
>> +"register"
>> +"admin_adhoc"))
>
> I suggest adding omemo (axelotl encryption) here, since this is one of
> the most important new features for XMPP.

Omemo only depends on PEP, which is enabled by default. So it should
work.

>> + "Multi-user chat (MUC) is Prosody's module for allowing you to create
>> +hosted chatrooms/conferences for XMPP users.
>> +
>> +General information on setting up and using MUC chatrooms can be found in 
>> our
>> +\"Chatrooms\" documentation (@url{http://prosody.im/doc/chatrooms}), which 
>> you
>> +should read if you are new to XMPP chatrooms.
>
> s/MUC chatrooms/ multi-user chatrooms/
> s/our/the/

Ok.



Re: [PATCH] gnu: Add Prosody service.

2017-01-05 Thread ng0
Hartmut Goebel  writes:

> Hi,
>
> Thanks for this service :-)
>
> Am 04.01.2017 um 22:55 schrieb Clément Lassieur:

>> +;;; Commentary:
>> +;;;
>> +;;; Messaging services.
>> +;;;
>> +;;; Code:
> […]
>> +;;; messaging.scm ends here
>
> I'd leave this comment away. It is of now use. We had a loner discussion
> about this here on the list in autum.

... which came to no real result, so these end comments are
perfectly fine and up to the person who contributes the file
first. So Clément, decide wether you want it or not.

Thanks for being faster than myself in creating this service
module. I'll just wait with psyced-service until this is in
master.

> -- 
> Regards
> Hartmut Goebel
>
> | Hartmut Goebel  | h.goe...@crazy-compilers.com   |
> | www.crazy-compilers.com | compilers which you thought are impossible |
>
>
>

-- 
♥Ⓐ  ng0
PGP keys and more: https://n0is.noblogs.org/ http://ng0.chaosnet.org



Re: [PATCH] gnu: Add Prosody service.

2017-01-05 Thread Hartmut Goebel
Hi,

Thanks for this service :-)

Am 04.01.2017 um 22:55 schrieb Clément Lassieur:
> +(define %default-modules-enabled
> +  '("roster"
> +"saslauth"
> +"tls"
> +"dialback"
> +"disco"
> +"private"
> +"vcard"
> +"version"
> +"uptime"
> +"time"
> +"ping"
> +"pep"
> +"register"
> +"admin_adhoc"))

I suggest adding omemo (axelotl encryption) here, since this is one of
the most important new features for XMPP.

> + "Multi-user chat (MUC) is Prosody's module for allowing you to create
> +hosted chatrooms/conferences for XMPP users.
> +
> +General information on setting up and using MUC chatrooms can be found in our
> +\"Chatrooms\" documentation (@url{http://prosody.im/doc/chatrooms}), which 
> you
> +should read if you are new to XMPP chatrooms.

s/MUC chatrooms/ multi-user chatrooms/
s/our/the/

> +;;; Commentary:
> +;;;
> +;;; Messaging services.
> +;;;
> +;;; Code:
[…]
> +;;; messaging.scm ends here

I'd leave this comment away. It is of now use. We had a loner discussion
about this here on the list in autum.

-- 
Regards
Hartmut Goebel

| Hartmut Goebel  | h.goe...@crazy-compilers.com   |
| www.crazy-compilers.com | compilers which you thought are impossible |




[PATCH] gnu: Add Prosody service.

2017-01-04 Thread Clément Lassieur
* gnu/services/messaging.scm: New file.
* gnu/services/configuration.scm: New exported procedures.
* gnu/packages/messaging.scm (prosody)[arguments]: Add 'fix-makefile'
  phase.
  In 'wrap-programs' phase, add 'openssl' and 'coreutils' to 'PATH'.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add gnu/services/messaging.scm.
* doc/guix.texi (Messaging Services): New section.
---
 doc/guix.texi  | 393 +-
 gnu/local.mk   |   1 +
 gnu/packages/messaging.scm |  48 ++-
 gnu/services/configuration.scm |   3 +
 gnu/services/messaging.scm | 728 +
 5 files changed, 1157 insertions(+), 16 deletions(-)
 create mode 100644 gnu/services/messaging.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index adc7fefca..1a092d169 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -29,7 +29,8 @@ Copyright @copyright{} 2016 John Darrington@*
 Copyright @copyright{} 2016 ng0@*
 Copyright @copyright{} 2016 Jan Nieuwenhuizen@*
 Copyright @copyright{} 2016 Julien Lepiller@*
-Copyright @copyright{} 2016 Alex ter Weele
+Copyright @copyright{} 2016 Alex ter Weele@*
+Copyright @copyright{} 2017 Clément Lassieur
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -204,6 +205,7 @@ Services
 * Desktop Services::D-Bus and desktop services.
 * Database Services::   SQL databases.
 * Mail Services::   IMAP, POP3, SMTP, and all that.
+* Messaging Services::  Messaging services.
 * Kerberos Services::   Kerberos services.
 * Web Services::Web servers.
 * Network File System:: NFS related services.
@@ -8094,6 +8096,7 @@ declaration.
 * Desktop Services::D-Bus and desktop services.
 * Database Services::   SQL databases.
 * Mail Services::   IMAP, POP3, SMTP, and all that.
+* Messaging Services::  Messaging services.
 * Kerberos Services::   Kerberos services.
 * Web Services::Web servers.
 * Network File System:: NFS related services.
@@ -11708,6 +11711,394 @@ remote servers.  Run @command{man smtpd.conf} for 
more information.
 @end table
 @end deftp
 
+@node Messaging Services
+@subsubsection Messaging Services
+
+@cindex messaging
+@cindex jabber
+@cindex XMPP
+The @code{(gnu services messaging)} module provides Guix service
+definitions for messaging services: currently only Prosody is supported.
+
+@subsubheading Prosody Service
+
+@deffn {Scheme Variable} prosody-service-type
+This is the type for the @uref{http://prosody.im, Prosody XMPP
+communication server}.  Its value must be a @code{prosody-configuration}
+record as in this example:
+
+@example
+(service prosody-service-type
+ (prosody-configuration
+  (modules-enabled (cons "groups" %default-modules-enabled))
+  (int-components
+   (list
+(int-component-configuration
+ (hostname "conference.example.net")
+ (plugin "muc")
+ (mod-muc (mod-muc-configuration)
+  (virtualhosts
+   (list
+(virtualhost-configuration
+ (domain "example.net"))
+@end example
+
+See below for details about @code{prosody-configuration}.
+
+@end deffn
+
+By default, Prosody does not need much configuration.  Only one
+@code{virtualhosts} field is needed: it specifies the domain you wish
+Prosody to serve.
+
+Prosodyctl will help you generate X.509 certificates and keys:
+
+@example
+prosodyctl cert request example.net
+@end example
+
+The available configuration parameters follow.  Each parameter
+definition is preceded by its type; for example, @samp{string-list foo}
+indicates that the @code{foo} parameter should be specified as a list of
+strings.  Types starting with @code{maybe-} denote parameters that won't
+show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
+
+There is also a way to specify the configuration as a string, if you
+have an old @code{prosody.cfg.lua} file that you want to port over from
+some other system; see the end for more details.
+
+@c The following documentation was initially generated by
+@c (generate-documentation) in (gnu services messaging).  Manually maintained
+@c documentation is better, so we shouldn't hesitate to edit below as
+@c needed.  However if the change you want to make to this documentation
+@c can be done in an automated way, it's probably easier to change
+@c (generate-documentation) than to make it below and have to deal with
+@c the churn as Prosody updates.
+
+Available @code{prosody-configuration} fields are:
+
+@deftypevr {@code{prosody-configuration} parameter} package prosody
+The Prosody package.
+@end deftypevr
+
+@deftypevr {@code{prosody-configuration} parameter} file-name data-path
+Location of the Prosody data storage directory.  See
+@url{http://prosody.im/doc/configure}.
+Defaults to @s

Re: [PATCH] gnu: Add prosody service

2016-11-27 Thread Clément Lassieur
> Which version of the patch should we review? :)

Oh...  I accidentally sent the patches with my professional address, but
it took a long time to get into the list, so I thought it did not work
and sent a second set of patches with my real address.

Please do not answer the mails sent with my professional address.

way1: http://lists.gnu.org/archive/html/guix-devel/2016-11/msg01074.html
way2: http://lists.gnu.org/archive/html/guix-devel/2016-11/msg01075.html

> If you are using `git format-patch` or `git send-email`, you can use
> --subject-prefix to version your patches.
>
> For example:
>
> $ git send-email --cover-letter -n --thread=shallow --subject-prefix=v2 master

Yes, next time I'll do this.  Sorry for the confusion.



Re: [PATCH] gnu: Add prosody service

2016-11-26 Thread Leo Famulari
On Sat, Nov 26, 2016 at 06:20:12PM +0100, Clément Lassieur wrote:
> From: Clément Lassieur 

Hi, thanks for working on this!

> 
> ---
>  gnu/local.mk   |   1 +
>  gnu/packages/messaging.scm |   3 +
>  gnu/services/messaging.scm | 787 
> +
>  3 files changed, 791 insertions(+)
>  create mode 100644 gnu/services/messaging.scm

Which version of the patch should we review? :)

If you are using `git format-patch` or `git send-email`, you can use
--subject-prefix to version your patches.

For example:

$ git send-email --cover-letter -n --thread=shallow --subject-prefix=v2 master



[PATCH] gnu: Add prosody service

2016-11-26 Thread Clément Lassieur
From: Clément Lassieur 

---
 gnu/local.mk   |   1 +
 gnu/packages/messaging.scm |   3 +
 gnu/services/messaging.scm | 787 +
 3 files changed, 791 insertions(+)
 create mode 100644 gnu/services/messaging.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 466a9ff..bdb6d4f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -408,6 +408,7 @@ GNU_SYSTEM_MODULES =\
   %D%/services/lirc.scm\
   %D%/services/mail.scm\
   %D%/services/mcron.scm   \
+  %D%/services/messaging.scm   \
   %D%/services/networking.scm  \
   %D%/services/nfs.scm \
   %D%/services/shepherd.scm\
diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 72b8906..5b7c01c 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -527,6 +527,9 @@ end-to-end encryption support; XML console.")
  ;; arguments.  Make it more tolerant.
  (substitute* "configure"
(("exit 1") ""))
+ ;; Use /etc/prosody as CFG_CONFIGDIR so prosodyctl finds it.
+ (substitute* "Makefile"
+   (("^INSTALLEDCONFIG =.*") "INSTALLEDCONFIG = /etc/prosody\n"))
  #t))
  (add-after 'install 'wrap-programs
(lambda* (#:key inputs outputs #:allow-other-keys)
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
new file mode 100644
index 000..138b1ef
--- /dev/null
+++ b/gnu/services/messaging.scm
@@ -0,0 +1,787 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Clément Lassieur 
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see .
+
+(define-module (gnu services messaging)
+  #:use-module (gnu packages messaging)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu services)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu system shadow)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+  #:use-module (guix packages)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-35)
+  #:use-module (ice-9 match)
+  #:export (&prosody-configuration-error
+prosody-configuration-error?
+
+prosody-service
+prosody-service-type
+prosody-configuration
+opaque-prosody-configuration
+
+virtualhost-configuration
+int-component-configuration
+ext-component-configuration
+
+mod-muc-configuration
+ssl-configuration
+
+%default-modules-enabled))
+
+;;; Commentary:
+;;;
+;;; Messaging services.
+;;;
+;;; Code:
+
+(define-condition-type &prosody-configuration-error &error
+  prosody-configuration-error?)
+
+(define (prosody-error message)
+  (raise (condition (&message (message message))
+(&prosody-configuration-error
+(define (prosody-configuration-field-error field val)
+  (prosody-error
+   (format #f "Invalid value for field ~a: ~s" field val)))
+(define (prosody-configuration-missing-field kind field)
+  (prosody-error
+   (format #f "~a configuration missing required field ~a" kind field)))
+
+(define-record-type* 
+  configuration-field make-configuration-field configuration-field?
+  (name configuration-field-name)
+  (type configuration-field-type)
+  (getter configuration-field-getter)
+  (predicate configuration-field-predicate)
+  (serializer configuration-field-serializer)
+  (default-value-thunk configuration-field-default-value-thunk)
+  (documentation configuration-field-documentation))
+
+(define (id ctx . parts)
+  (datum->syntax ctx (apply symbol-append (map syntax->datum parts
+
+(define-syntax define-maybe
+  (lambda (x)
+(syntax-case x ()
+  ((_ stem)
+   (with-syntax
+   ((stem?(id #'stem #'stem #'?))
+(maybe-stem?  (id #'stem #'maybe- #'stem #'?))
+(serialize-stem   (id #'stem #'serialize- #'stem))
+(serialize-maybe-stem (id #'stem #'serialize-maybe- #'stem)))
+ #'(begin
+ (define (maybe-stem? val)
+   (or (eq? val 'disabled) (stem? val)))
+ (define (serialize-maybe-stem field-name val)
+   (when (s

[PATCH] gnu: Add prosody service

2016-11-26 Thread Clément Lassieur
From: Clément Lassieur 

---
 gnu/local.mk   |   1 +
 gnu/packages/messaging.scm |   3 +
 gnu/services/messaging.scm | 833 +
 3 files changed, 837 insertions(+)
 create mode 100644 gnu/services/messaging.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 466a9ff..bdb6d4f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -408,6 +408,7 @@ GNU_SYSTEM_MODULES =\
   %D%/services/lirc.scm\
   %D%/services/mail.scm\
   %D%/services/mcron.scm   \
+  %D%/services/messaging.scm   \
   %D%/services/networking.scm  \
   %D%/services/nfs.scm \
   %D%/services/shepherd.scm\
diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 72b8906..5b7c01c 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -527,6 +527,9 @@ end-to-end encryption support; XML console.")
  ;; arguments.  Make it more tolerant.
  (substitute* "configure"
(("exit 1") ""))
+ ;; Use /etc/prosody as CFG_CONFIGDIR so prosodyctl finds it.
+ (substitute* "Makefile"
+   (("^INSTALLEDCONFIG =.*") "INSTALLEDCONFIG = /etc/prosody\n"))
  #t))
  (add-after 'install 'wrap-programs
(lambda* (#:key inputs outputs #:allow-other-keys)
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
new file mode 100644
index 000..b10f3f4
--- /dev/null
+++ b/gnu/services/messaging.scm
@@ -0,0 +1,833 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Clément Lassieur 
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see .
+
+(define-module (gnu services messaging)
+  #:use-module (gnu packages messaging)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu services)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu system shadow)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+  #:use-module (guix packages)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-35)
+  #:use-module (ice-9 match)
+  #:export (&prosody-configuration-error
+prosody-configuration-error?
+
+prosody-service
+prosody-service-type
+prosody-configuration
+opaque-prosody-configuration
+
+virtualhost-configuration
+int-component-configuration
+ext-component-configuration
+
+mod-muc-configuration
+ssl-configuration
+
+%default-modules-enabled))
+
+;;; Commentary:
+;;;
+;;; Messaging services.
+;;;
+;;; Code:
+
+(define-condition-type &prosody-configuration-error &error
+  prosody-configuration-error?)
+
+(define (prosody-error message)
+  (raise (condition (&message (message message))
+(&prosody-configuration-error
+(define (prosody-configuration-field-error field val)
+  (prosody-error
+   (format #f "Invalid value for field ~a: ~s" field val)))
+(define (prosody-configuration-missing-field kind field)
+  (prosody-error
+   (format #f "~a configuration missing required field ~a" kind field)))
+
+(define-record-type* 
+  configuration-field make-configuration-field configuration-field?
+  (name configuration-field-name)
+  (type configuration-field-type)
+  (getter configuration-field-getter)
+  (predicate configuration-field-predicate)
+  (serializer configuration-field-serializer)
+  (default-value-thunk configuration-field-default-value-thunk)
+  (documentation configuration-field-documentation))
+
+(define (id ctx . parts)
+  (datum->syntax ctx (apply symbol-append (map syntax->datum parts
+
+(define-syntax define-maybe
+  (lambda (x)
+(syntax-case x ()
+  ((_ stem)
+   (with-syntax
+   ((stem?(id #'stem #'stem #'?))
+(maybe-stem?  (id #'stem #'maybe- #'stem #'?))
+(serialize-stem   (id #'stem #'serialize- #'stem))
+(serialize-maybe-stem (id #'stem #'serialize-maybe- #'stem)))
+ #'(begin
+ (define (maybe-stem? val)
+   (or (eq? val 'disabled) (stem? val)))
+ (define (serialize-maybe-stem field-name val)
+   (when (s

[PATCH] gnu: Add prosody service

2016-11-26 Thread Clément Lassieur
---
 gnu/local.mk   |   1 +
 gnu/packages/messaging.scm |   3 +
 gnu/services/messaging.scm | 833 +
 3 files changed, 837 insertions(+)
 create mode 100644 gnu/services/messaging.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 466a9ff..bdb6d4f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -408,6 +408,7 @@ GNU_SYSTEM_MODULES =\
   %D%/services/lirc.scm\
   %D%/services/mail.scm\
   %D%/services/mcron.scm   \
+  %D%/services/messaging.scm   \
   %D%/services/networking.scm  \
   %D%/services/nfs.scm \
   %D%/services/shepherd.scm\
diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 72b8906..5b7c01c 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -527,6 +527,9 @@ end-to-end encryption support; XML console.")
  ;; arguments.  Make it more tolerant.
  (substitute* "configure"
(("exit 1") ""))
+ ;; Use /etc/prosody as CFG_CONFIGDIR so prosodyctl finds it.
+ (substitute* "Makefile"
+   (("^INSTALLEDCONFIG =.*") "INSTALLEDCONFIG = /etc/prosody\n"))
  #t))
  (add-after 'install 'wrap-programs
(lambda* (#:key inputs outputs #:allow-other-keys)
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
new file mode 100644
index 000..b10f3f4
--- /dev/null
+++ b/gnu/services/messaging.scm
@@ -0,0 +1,833 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Clément Lassieur 
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see .
+
+(define-module (gnu services messaging)
+  #:use-module (gnu packages messaging)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu services)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu system shadow)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+  #:use-module (guix packages)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-35)
+  #:use-module (ice-9 match)
+  #:export (&prosody-configuration-error
+prosody-configuration-error?
+
+prosody-service
+prosody-service-type
+prosody-configuration
+opaque-prosody-configuration
+
+virtualhost-configuration
+int-component-configuration
+ext-component-configuration
+
+mod-muc-configuration
+ssl-configuration
+
+%default-modules-enabled))
+
+;;; Commentary:
+;;;
+;;; Messaging services.
+;;;
+;;; Code:
+
+(define-condition-type &prosody-configuration-error &error
+  prosody-configuration-error?)
+
+(define (prosody-error message)
+  (raise (condition (&message (message message))
+(&prosody-configuration-error
+(define (prosody-configuration-field-error field val)
+  (prosody-error
+   (format #f "Invalid value for field ~a: ~s" field val)))
+(define (prosody-configuration-missing-field kind field)
+  (prosody-error
+   (format #f "~a configuration missing required field ~a" kind field)))
+
+(define-record-type* 
+  configuration-field make-configuration-field configuration-field?
+  (name configuration-field-name)
+  (type configuration-field-type)
+  (getter configuration-field-getter)
+  (predicate configuration-field-predicate)
+  (serializer configuration-field-serializer)
+  (default-value-thunk configuration-field-default-value-thunk)
+  (documentation configuration-field-documentation))
+
+(define (id ctx . parts)
+  (datum->syntax ctx (apply symbol-append (map syntax->datum parts
+
+(define-syntax define-maybe
+  (lambda (x)
+(syntax-case x ()
+  ((_ stem)
+   (with-syntax
+   ((stem?(id #'stem #'stem #'?))
+(maybe-stem?  (id #'stem #'maybe- #'stem #'?))
+(serialize-stem   (id #'stem #'serialize- #'stem))
+(serialize-maybe-stem (id #'stem #'serialize-maybe- #'stem)))
+ #'(begin
+ (define (maybe-stem? val)
+   (or (eq? val 'disabled) (stem? val)))
+ (define (serialize-maybe-stem field-name val)
+   (when (stem? val) (serialize-stem

[PATCH] gnu: Add prosody service

2016-11-26 Thread Clément Lassieur
---
 gnu/local.mk   |   1 +
 gnu/packages/messaging.scm |   3 +
 gnu/services/messaging.scm | 787 +
 3 files changed, 791 insertions(+)
 create mode 100644 gnu/services/messaging.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 466a9ff..bdb6d4f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -408,6 +408,7 @@ GNU_SYSTEM_MODULES =\
   %D%/services/lirc.scm\
   %D%/services/mail.scm\
   %D%/services/mcron.scm   \
+  %D%/services/messaging.scm   \
   %D%/services/networking.scm  \
   %D%/services/nfs.scm \
   %D%/services/shepherd.scm\
diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 72b8906..5b7c01c 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -527,6 +527,9 @@ end-to-end encryption support; XML console.")
  ;; arguments.  Make it more tolerant.
  (substitute* "configure"
(("exit 1") ""))
+ ;; Use /etc/prosody as CFG_CONFIGDIR so prosodyctl finds it.
+ (substitute* "Makefile"
+   (("^INSTALLEDCONFIG =.*") "INSTALLEDCONFIG = /etc/prosody\n"))
  #t))
  (add-after 'install 'wrap-programs
(lambda* (#:key inputs outputs #:allow-other-keys)
diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm
new file mode 100644
index 000..138b1ef
--- /dev/null
+++ b/gnu/services/messaging.scm
@@ -0,0 +1,787 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Clément Lassieur 
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see .
+
+(define-module (gnu services messaging)
+  #:use-module (gnu packages messaging)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu services)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu system shadow)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+  #:use-module (guix packages)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-35)
+  #:use-module (ice-9 match)
+  #:export (&prosody-configuration-error
+prosody-configuration-error?
+
+prosody-service
+prosody-service-type
+prosody-configuration
+opaque-prosody-configuration
+
+virtualhost-configuration
+int-component-configuration
+ext-component-configuration
+
+mod-muc-configuration
+ssl-configuration
+
+%default-modules-enabled))
+
+;;; Commentary:
+;;;
+;;; Messaging services.
+;;;
+;;; Code:
+
+(define-condition-type &prosody-configuration-error &error
+  prosody-configuration-error?)
+
+(define (prosody-error message)
+  (raise (condition (&message (message message))
+(&prosody-configuration-error
+(define (prosody-configuration-field-error field val)
+  (prosody-error
+   (format #f "Invalid value for field ~a: ~s" field val)))
+(define (prosody-configuration-missing-field kind field)
+  (prosody-error
+   (format #f "~a configuration missing required field ~a" kind field)))
+
+(define-record-type* 
+  configuration-field make-configuration-field configuration-field?
+  (name configuration-field-name)
+  (type configuration-field-type)
+  (getter configuration-field-getter)
+  (predicate configuration-field-predicate)
+  (serializer configuration-field-serializer)
+  (default-value-thunk configuration-field-default-value-thunk)
+  (documentation configuration-field-documentation))
+
+(define (id ctx . parts)
+  (datum->syntax ctx (apply symbol-append (map syntax->datum parts
+
+(define-syntax define-maybe
+  (lambda (x)
+(syntax-case x ()
+  ((_ stem)
+   (with-syntax
+   ((stem?(id #'stem #'stem #'?))
+(maybe-stem?  (id #'stem #'maybe- #'stem #'?))
+(serialize-stem   (id #'stem #'serialize- #'stem))
+(serialize-maybe-stem (id #'stem #'serialize-maybe- #'stem)))
+ #'(begin
+ (define (maybe-stem? val)
+   (or (eq? val 'disabled) (stem? val)))
+ (define (serialize-maybe-stem field-name val)
+   (when (stem? val) (serialize-stem