guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#77396] [PATCH] services: Add ngircd-service-type.


From: Ludovic Courtès
Subject: [bug#77396] [PATCH] services: Add ngircd-service-type.
Date: Tue, 01 Apr 2025 14:16:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hello!

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> * gnu/services/messaging.scm (pascal-case, ngircd-serialize-string)
> (ngircd-serialize-boolean, ngircd-serialize-file-like)
> (ngircd-serialize-list-of-strings, ngircd-serialize-list-of-ports)
> (ngircd-serialize-number, ngircd-serialize-port)
> (string-or-number?, ngircd-serialize-string-or-number): New procedures.
> (ngircd-global, ngircd-limits, ngircd-options, ngircd-ssl)
> (ngircd-operator, ngircd-server, ngircd-channel)
> (ngircd-configuration): New configurations.
> (serialize-ngircd-global, serialize-ngircd-limits)
> (serialize-ngircd-options, serialize-ngircd-operator)
> (serialize-list-of-ngircd-operators, serialize-ngircd-server)
> (serialize-ngircd-channel, serialize-list-of-ngircd-channels)
> (serialize-ngircd-configuration): New procedures.
> (list-of-ngircd-operators?, list-of-ngircd-servers?)
> (list-of-ngircd-channels?): New predicates.
> (ngircd-generate-documentation): New procedure.
> (ngircd-user+group, ngircd-account, ngircd-wrapper): Likewise.
> (ngircd-shepherd-service): New shepherd service.
> (%ngircd-activation): New procedure.
> (ngircd-service-type): New service type.
> * gnu/tests/messaging.scm (%ngircd-os): New variable.
> (run-ngircd-test): New procedure.
> (%test-ngircd): New test.
> * doc/guix.texi (Messaging Services): Document it.
>
> Change-Id: I3ce9a7fd0b33afab22cf15942a1db0cf5b12bfdb

[…]

> +@cindex IRC (Internet Relay Chat)
> +
> +@url{https://ngircd.barton.de/, ngIRCd}, is a lightweight @acronym{IRCd,
> +Internet Relay Chat daemon}, which can be used to host your own IRC
> +server.

Could you add an example configuration, as is usually done for services?
It’s always nice to have something to copy/paste to get started.

> +            <ngircd-configuration>
> +            ngircd-configuration
> +            ngircd-configuration?
> +            <ngircd-global>
> +            ngircd-global
> +            ngircd-global?
> +            <ngircd-limits>
> +            ngircd-limits
> +            ngircd-limits?
> +            <ngircd-options>
> +            ngircd-options
> +            ngircd-options?
> +            <ngircd-ssl>
> +            ngircd-ssl
> +            ngircd-ssl?
> +            <ngircd-operator>
> +            ngircd-operator
> +            ngircd-operator?
> +            <ngircd-server>
> +            ngircd-server
> +            ngircd-server?
> +            <ngircd-channel>

Please don’t export record type descriptors like <ngircd-configuration>
since that makes it impossible to provide any guarantee (ABI, validity
of fields, etc.).

> +(define (ngircd-shepherd-service config)
> +  (match-record config <ngircd-configuration>
> +                (ngircd debug? global)
> +    (let ((ngircd.conf (serialize-ngircd-configuration config))
> +          (ngircd (file-append ngircd "/sbin/ngircd"))
> +          (pid-file (ngircd-global-pid-file global))
> +          (user group (ngircd-user+group config)))
> +      (list (shepherd-service
> +             (provision '(ngircd))
> +             (requirement '(user-processes networking syslogd))

I would drop ‘networking’: see <https://issues.guix.gnu.org/66306>.

> +             (actions (list (shepherd-configuration-action ngircd.conf)))
> +             (start #~(make-forkexec-constructor
> +                       (append (list #$(ngircd-wrapper config)
> +                                     "--nodaemon" "--syslog"

I’d use #:log-file and drop ‘--syslog’; I find it more convenient.

> +                                     "--config" #$ngircd.conf)
> +                               (if #$debug?
> +                                   '("--debug")
> +                                   '()))
> +                       #:pid-file #$pid-file))

If ngircd supports socket activation, I’d suggest using
‘make-systemd-constructor’ instead of #:pid-file: it equally achieves
startup synchronization, but it allows for shorter startup times and can
start the daemon lazily on-demand.

> +        (mkdir-p/perms #$(dirname pid-file) pw #o755)
> +        (system (string-join
> +                 (list #$(file-append ngircd "/sbin/ngircd")
> +                       "--configtest" "--config" #$ngircd.conf
> +                       ;; Ensure stdin is not a TTY to avoid pausing for a 
> key
> +                       ;; during boot when a problem is detected.
> +                       "<" "/dev/null"))))))

I think you can do:

  (parameterize ((current-input-port (%make-void-port "r")))
    (system* #$(file-append …) "--configtest" …))

But! if it’s about checking the configuration, I would do it in a
derivation (instead of at activation time), similar to how this is done
for mcron.

> +          (test-assert "ngircd listens on TCP port 6667"
> +            (wait-for-tcp-port 6667 marionette))

Maybe try a /JOIN command or whatever?

Thanks!

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]