From f5b0046658ffe5f600980743cea52d7a916035ad Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 4 Aug 2023 20:44:00 +0200 Subject: [PATCH] Add znc service --- services/znc.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 services/znc.scm diff --git a/services/znc.scm b/services/znc.scm new file mode 100644 index 0000000..ca3be06 --- /dev/null +++ b/services/znc.scm @@ -0,0 +1,64 @@ +(define-module (services znc) + #:use-module (gnu build linux-container) + #:use-module (gnu packages admin) + #:use-module (gnu packages messaging) + #:use-module (gnu services) + #:use-module (gnu services shepherd) + #:use-module (gnu system file-systems) + #:use-module (gnu system shadow) + #:use-module (guix gexp) + #:use-module (guix least-authority) + #:use-module (guix records) + #:use-module (ice-9 match) + #:export (znc-configuration znc-service-type)) + +(define-record-type* + znc-configuration make-znc-configuration + znc-configuration? + (package znc-configuration-package (default znc))) + +(define znc-shepherd-service + (match-lambda + (($ package) + (let ((znc* (least-authority-wrapper + (file-append znc "/bin/znc") + #:name "znc" + #:mappings (list (file-system-mapping + (source "/var/lib/znc") + (target source) + (writable? #t))) + #:namespaces (delq 'net %namespaces)))) + (list (shepherd-service + (provision '(znc)) + (requirement '(user-processes networking)) + (start #~(make-forkexec-constructor + (list #$znc* "--foreground" "--datadir=/var/lib/znc") + #:user "znc" + #:group "znc")) + (stop #~(make-kill-destructor)))))))) + +(define %znc-account + (list + (user-group + (name "znc") + (system? #t)) + (user-account + (name "znc") + (group "znc") + (system? #t) + (comment "ZNC daemon user") + (home-directory "/var/lib/znc") + (shell (file-append shadow "/sbin/nologin"))))) + +(define znc-service-type + (service-type (name 'znc) + (extensions + (list (service-extension shepherd-root-service-type + znc-shepherd-service) + (service-extension profile-service-type + (compose list znc-configuration-package)) + (service-extension account-service-type + (const %znc-account)))) + (default-value (znc-configuration)) + (description + "Run the ZNC IRC bouncer.")))