diff mbox series

[bug#61483,v2,3/5] DRAFT gnu: home: services: Add home-znc-service-type.

Message ID 20230216155355.11106-3-janneke@gnu.org
State New
Headers show
Series [bug#61483,v2,1/5] DRAFT gnu: home: services: Add home-git-daemon-service-type. | expand

Commit Message

Janneke Nieuwenhuizen Feb. 16, 2023, 3:53 p.m. UTC
* gnu/home/services/shepherd-xyz.scm
(<home-znc-configuration>): New type.
(home-znc-services): New procedure.
(home-znc-service-type): New variable.
---
 gnu/home/services/shepherd-xyz.scm | 43 +++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

Comments

Ludovic Courtès March 4, 2023, 5:06 p.m. UTC | #1
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

> * gnu/home/services/shepherd-xyz.scm
> (<home-znc-configuration>): New type.
> (home-znc-services): New procedure.
> (home-znc-service-type): New variable.

I’d make it ‘messaging.scm’.

With that an entry in the manual, it will be ready to go!

Ludo’.
diff mbox series

Patch

diff --git a/gnu/home/services/shepherd-xyz.scm b/gnu/home/services/shepherd-xyz.scm
index 75f3770ffc..856a5e7246 100644
--- a/gnu/home/services/shepherd-xyz.scm
+++ b/gnu/home/services/shepherd-xyz.scm
@@ -25,6 +25,7 @@  (define-module (gnu home services shepherd-xyz)
 
   #:use-module (gnu home services)
   #:use-module (gnu home services shepherd)
+  #:use-module (gnu packages messaging)
   #:use-module (gnu packages ssh)
   #:use-module (gnu packages version-control)
   #:use-module (gnu services configuration)
@@ -35,7 +36,9 @@  (define-module (gnu home services shepherd-xyz)
   #:export (home-git-daemon-configuration
             home-git-daemon-service-type
             home-ssh-agent-configuration
-            home-ssh-agent-service-type))
+            home-ssh-agent-service-type
+            home-znc-configuration
+            home-znc-service-type))
 
 ;;; Commentary:
 ;;
@@ -178,3 +181,41 @@  (define home-ssh-agent-service-type
                              home-ssh-agent-services)))
    (description
     "Install and configure the ssh-agent as a shepherd service.")))
+
+
+;;;
+;;; Znc.
+;;;
+(define-record-type* <home-znc-configuration>
+  home-znc-configuration make-home-znc-configuration
+  home-znc-configuration?
+  (znc           home-znc-znc           ;string
+                 (default znc))
+  (extra-options home-znc-extra-options ;list of string
+                 (default '())))
+
+(define (home-znc-services config)
+  "Return a <shepherd-service> for znc with CONFIG."
+  (match config
+    (($ <home-znc-configuration> znc extra-options)
+     (let* ((znc (file-append znc "/bin/znc"))
+            (command `(,znc
+                       "--foreground"
+                       ,@extra-options))
+            (log-file (string-append %user-log-dir "/znc.log")))
+       (list (shepherd-service
+              (documentation "Run the znc IRC bouncer.")
+              (provision '(znc))
+              (start #~(make-forkexec-constructor '#$command
+                                                  #:log-file #$log-file))
+              (stop #~(make-kill-destructor))))))))
+
+(define home-znc-service-type
+  (service-type
+   (name 'home-znc)
+   (default-value (home-znc-configuration))
+   (extensions
+    (list (service-extension home-shepherd-service-type
+                             home-znc-services)))
+   (description
+    "Install and configure znc as a shepherd service.")))