mastostart-guix/mastostart-gnu/services/mastostart.scm
Giacomo Leidi dd46539c94 mastostart-gnu: Agginto mastostart-service.
* mastostart-gnu/services/mastostart.scm: Nuovo file,
(mastostart-service): Nuova variabile,
(mastostart-configuration): Nuova variabile.
2020-05-10 20:39:48 +02:00

64 lines
2.3 KiB
Scheme

(define-module (mastostart-gnu services mastostart)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (gnu system shadow)
#:use-module (gnu packages admin)
#:use-module (gnu packages base)
#:use-module (guix records)
#:use-module (guix gexp)
#:use-module (mastostart-gnu packages mastostart)
#:export (mastostart-service
mastostart-service-type
mastostart-configuration
mastostart-configuration?))
(define-record-type* <mastostart-configuration>
mastostart-configuration make-mastostart-configuration
mastostart-configuration?
(mastostart mastostart-configuration-mastostart
(default mastostart))
(webroot mastostart-configuration-webroot
(default "/srv"))
(reference-email mastostart-configuration-reference-email
(default "goodoldpaul@autistici.org"))
(test-email mastostart-configuration-test-email
(default "goodoldpaul@autistici.org"))
(memory-limit mastostart-configuration-memory-limit
(default "1G")))
(define %mastostart-accounts
(list (user-group
(name "mastostart")
(system? #t))
(user-account
(name "mastostart")
(group "mastostart")
(system? #t)
(home-directory "/var/empty")
(shell (file-append shadow "/sbin/nologin")))))
(define (mastostart-shepherd-service config)
(list
(let ((mastostart (mastostart-configuration-mastostart config))
(webroot (mastostart-configuration-webroot config)))
(shepherd-service
(provision '(mastostart))
(one-shot? #t)
(requirement '(httpd mysql))
(documentation "Start serving the MastodonStartpage.")
(start #~(make-forkexec-constructor
(list (string-append #$coreutils "/bin/ln")
"-s"
(string-append #$mastostart "/web/")
#$webroot)))
(stop #~(make-kill-destructor))))))
(define mastostart-service-type
(service-type
(name 'mastostart)
(extensions
(list (service-extension account-service-type
(const %mastostart-accounts))
(service-extension shepherd-root-service-type
mastostart-shepherd-service)))
(default-value (mastostart-configuration))))