64 lines
2.4 KiB
Scheme
64 lines
2.4 KiB
Scheme
(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>
|
|
znc-configuration make-znc-configuration
|
|
znc-configuration?
|
|
(package znc-configuration-package (default znc)))
|
|
|
|
(define znc-shepherd-service
|
|
(match-lambda
|
|
(($ <znc-configuration> 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.")))
|