[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/10: services: Add gmnisrv web service.
From: |
guix-commits |
Subject: |
03/10: services: Add gmnisrv web service. |
Date: |
Tue, 27 Oct 2020 13:01:21 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 2ade5bdeb8978d252f298df7150b8d1a359e618d
Author: Alexandru-Sergiu Marton <brown121407@posteo.ro>
AuthorDate: Sun Oct 25 02:19:39 2020 +0300
services: Add gmnisrv web service.
* gnu/services/web.scm (<gmnisrv-configuration>): New record type.
(%default-gmnisrv-config-file): New variable.
(%gmnisrv-accounts, %gmnisrv-activation): New variables.
(gmnisrv-shepherd-service): New procedure.
(gmnisrv-service-type): New variable.
* doc/guix.texi (Web Services): Document it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
doc/guix.texi | 35 +++++++++++++++++++++++++
gnu/services/web.scm | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index a8aa2de..0a7857f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -81,6 +81,7 @@ Copyright @copyright{} 2020 R Veera Kumar@*
Copyright @copyright{} 2020 Pierre Langlois@*
Copyright @copyright{} 2020 pinoaffe@*
Copyright @copyright{} 2020 André Batista@*
+Copyright @copyright{} 2020 Alexandru-Sergiu Marton@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -23549,6 +23550,40 @@ Thus, make sure to add @code{nss-certs} or another
certificate package to the
more information on X.509 certificates.
@end quotation
+@subsubheading gmnisrv
+
+@cindex gmnisrv
+The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
+simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
+
+@deffn {Scheme Variable} gmnisrv-service-type
+This is the type of the gmnisrv service, whose value should be a
+@code{gmnisrv-configuration} object, as in this example:
+
+@lisp
+(service gmnisrv-service-type
+ (gmnisrv-configuration
+ (config-file (local-file "./my-gmnisrv.ini"))))
+@end lisp
+@end deffn
+
+@deftp {Data Type} gmnisrv-configuration
+Data type representing the configuration of gmnisrv.
+
+@table @asis
+@item @code{package} (default: @var{gmnisrv})
+Package object of the gmnisrv server.
+
+@item @code{config-file} (default: @code{%default-gmnisrv-config-file})
+File-like object of the gmnisrv configuration file to use. The default
+configuration listens on port 1965 and serves files from
+@file{/srv/gemini}. Certificates are stored in
+@file{/var/lib/gemini/certs}. For more information, run @command{man
+gmnisrv} and @command{man gmnisrv.ini}.
+
+@end table
+@end deftp
+
@node Certificate Services
@subsection Certificate Services
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 2384ec6..7e17dac 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2020 Alexandru-Sergiu Marton <brown121407@posteo.ro>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1798,3 +1799,75 @@ WSGIPassAuthorization On
"Run Mumi, a Web interface to the Debbugs bug-tracking server.")
(default-value
(mumi-configuration))))
+
+(define %default-gmnisrv-config-file
+ (plain-file "gmnisrv.ini" "
+listen=0.0.0.0:1965 [::]:1965
+
+[:tls]
+store=/var/lib/gemini/certs
+
+organization=gmnisrv on Guix user
+
+[localhost]
+root=/srv/gemini
+"))
+
+(define-record-type* <gmnisrv-configuration>
+ gmnisrv-configuration make-gmnisrv-configuration
+ gmnisrv-configuration?
+ (package gmnisrv-configuration-package
+ (default gmnisrv))
+ (config-file gmnisrv-configuration-config-file
+ (default %default-gmnisrv-config-file)))
+
+(define gmnisrv-shepherd-service
+ (match-lambda
+ (($ <gmnisrv-configuration> package config-file)
+ (list (shepherd-service
+ (provision '(gmnisrv))
+ (requirement '(networking))
+ (documentation "Run the gmnisrv Gemini server.")
+ (start (let ((gmnisrv (file-append package "/bin/gmnisrv")))
+ #~(make-forkexec-constructor
+ (list #$gmnisrv "-C" #$config-file)
+ #:user "gmnisrv" #:group "gmnisrv"
+ #:log-file "/var/log/gmnisrv.log")))
+ (stop #~(make-kill-destructor)))))))
+
+(define %gmnisrv-accounts
+ (list (user-group (name "gmnisrv") (system? #t))
+ (user-account
+ (name "gmnisrv")
+ (group "gmnisrv")
+ (system? #t)
+ (comment "gmnisrv Gemini server")
+ (home-directory "/var/empty")
+ (shell (file-append shadow "/sbin/nologin")))))
+
+(define %gmnisrv-activation
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+
+ (mkdir-p "/var/lib/gemini/certs")
+ (let* ((pw (getpwnam "gmnisrv"))
+ (uid (passwd:uid pw))
+ (gid (passwd:gid pw)))
+ (chown "/var/lib/gemini" uid gid)
+ (chown "/var/lib/gemini/certs" uid gid)))))
+
+(define gmnisrv-service-type
+ (service-type
+ (name 'guix)
+ (extensions
+ (list (service-extension activation-service-type
+ (const %gmnisrv-activation))
+ (service-extension account-service-type
+ (const %gmnisrv-accounts))
+ (service-extension shepherd-root-service-type
+ gmnisrv-shepherd-service)))
+ (description
+ "Run the gmnisrv Gemini server.")
+ (default-value
+ (gmnisrv-configuration))))
- branch master updated (f0c6093 -> 6799e6e), guix-commits, 2020/10/27
- 01/10: services: hpcguix-web: Set 'XDG_CACHE_HOME' to a writable directory., guix-commits, 2020/10/27
- 02/10: gnu: Add gmnisrv., guix-commits, 2020/10/27
- 05/10: gnu: Add go-golang-org-x-xerrors., guix-commits, 2020/10/27
- 03/10: services: Add gmnisrv web service.,
guix-commits <=
- 10/10: maint: Include 'guix-daemon.cil.in' in the distribution., guix-commits, 2020/10/27
- 04/10: gnu: alacritty: Add search path for 'TERMINFO_DIRS'., guix-commits, 2020/10/27
- 08/10: gnu: Add go-github-com-bep-golibsass., guix-commits, 2020/10/27
- 06/10: gnu: go-github-com-google-go-cmp-cmp: Update to 0.5.2., guix-commits, 2020/10/27
- 09/10: maint: Add 'etc/gnu-store.mount.in' to the distribution., guix-commits, 2020/10/27
- 07/10: gnu: Add go-github-com-frankban-quicktest., guix-commits, 2020/10/27