mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2025-01-22 02:05:25 +00:00
services: Add docker-mailserver-service-type.
* rosenthal/services/mail.scm: New file.
This commit is contained in:
parent
d219e6e520
commit
04ad9e3b30
74
rosenthal/services/mail.scm
Normal file
74
rosenthal/services/mail.scm
Normal file
@ -0,0 +1,74 @@
|
||||
;; SPDX-FileCopyrightText: 2024 Hilton Chain <hako@ultrarare.space>
|
||||
;;
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
(define-module (rosenthal services mail)
|
||||
#:use-module (srfi srfi-26)
|
||||
#:use-module (guix records)
|
||||
#:use-module (gnu services)
|
||||
#:use-module (gnu services admin)
|
||||
#:use-module (gnu services configuration)
|
||||
#:use-module (gnu services docker)
|
||||
#:export (docker-mailserver-configuration
|
||||
docker-mailserver-service-type))
|
||||
|
||||
;;;
|
||||
;;; Docker Mailserver
|
||||
;;; https://docker-mailserver.github.io/docker-mailserver/latest/
|
||||
;;;
|
||||
|
||||
(define-configuration docker-mailserver-configuration
|
||||
(data-directory
|
||||
(string "/var/lib/docker-mailserver")
|
||||
"Directory to store Docker Mailserver data.")
|
||||
(log-file
|
||||
(string "/var/log/docker-mailserver.log")
|
||||
"Path to log file.")
|
||||
(shepherd-requirement
|
||||
(list-of-symbols '())
|
||||
"List of Shepherd service dependencies.")
|
||||
(options
|
||||
(alist '())
|
||||
"Alist of Docker Mailserver configuration. See also
|
||||
@url{https://docker-mailserver.github.io/docker-mailserver/latest/config/environment/}.")
|
||||
(extra-arguments
|
||||
(list '())
|
||||
"List of extra Docker arguments.")
|
||||
(no-serialization))
|
||||
|
||||
(define docker-mailserver-log-rotations
|
||||
(match-record-lambda <docker-mailserver-configuration>
|
||||
(log-file)
|
||||
(list (log-rotation
|
||||
(files (list log-file))))))
|
||||
|
||||
(define docker-mailserver-oci-containers
|
||||
(match-record-lambda <docker-mailserver-configuration>
|
||||
(data-directory log-file shepherd-requirement options extra-arguments)
|
||||
(let ((docker-mailserver-path
|
||||
(cut string-append data-directory <>)))
|
||||
(list (oci-container-configuration
|
||||
(environment options)
|
||||
(image "ghcr.io/docker-mailserver/docker-mailserver:latest")
|
||||
(provision "docker-mailserver")
|
||||
(requirement shepherd-requirement)
|
||||
(log-file log-file)
|
||||
(network "host")
|
||||
(volumes
|
||||
`((,(docker-mailserver-path "/data") . "/var/mail")
|
||||
(,(docker-mailserver-path "/state") . "/var/mail-state")
|
||||
(,(docker-mailserver-path "/logs") . "/var/log/mail")
|
||||
(,(docker-mailserver-path "/config") . "/tmp/docker-mailserver")
|
||||
("/etc/localtime" . "/etc/localtime:ro")))
|
||||
(extra-arguments extra-arguments))))))
|
||||
|
||||
(define docker-mailserver-service-type
|
||||
(service-type
|
||||
(name 'docker-mailserver)
|
||||
(extensions
|
||||
(list (service-extension oci-container-service-type
|
||||
docker-mailserver-oci-containers)
|
||||
(service-extension rottlog-service-type
|
||||
docker-mailserver-log-rotations)))
|
||||
(default-value (docker-mailserver-configuration))
|
||||
(description "Run Docker Mailserver.")))
|
Loading…
Reference in New Issue
Block a user