From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id eWshAFiZlF9oOgAA0tVLHw (envelope-from ) for ; Sat, 24 Oct 2020 21:15:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id gDdDN1eZlF+rSwAA1q6Kng (envelope-from ) for ; Sat, 24 Oct 2020 21:15:03 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 63286940418 for ; Sat, 24 Oct 2020 21:15:03 +0000 (UTC) Received: from localhost ([::1]:35244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWQ1J-0007iS-JC for larch@yhetil.org; Sat, 24 Oct 2020 16:20:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kWQ1C-0007iF-IQ for guix-patches@gnu.org; Sat, 24 Oct 2020 16:20:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kWQ1C-0002wy-90 for guix-patches@gnu.org; Sat, 24 Oct 2020 16:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kWQ1C-0005U4-4x for guix-patches@gnu.org; Sat, 24 Oct 2020 16:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#44099] [PATCH] services: Add gmnisrv web service. Resent-From: Alexandru-Sergiu Marton Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 24 Oct 2020 20:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44099 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 44099@debbugs.gnu.org Cc: Alexandru-Sergiu Marton Received: via spool by 44099-submit@debbugs.gnu.org id=B44099.160357078621038 (code B ref 44099); Sat, 24 Oct 2020 20:20:02 +0000 Received: (at 44099) by debbugs.gnu.org; 24 Oct 2020 20:19:46 +0000 Received: from localhost ([127.0.0.1]:35256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWQ0t-0005TB-1U for submit@debbugs.gnu.org; Sat, 24 Oct 2020 16:19:46 -0400 Received: from mout02.posteo.de ([185.67.36.66]:55827) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWQ0q-0005Sx-Gy for 44099@debbugs.gnu.org; Sat, 24 Oct 2020 16:19:42 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id BE2BE2400FC for <44099@debbugs.gnu.org>; Sat, 24 Oct 2020 22:19:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.ro; s=2017; t=1603570773; bh=nRZwvtFV6S9sbmbH2oRjFmwFrlQL8LTASdybkihPyic=; h=From:To:Cc:Subject:Date:From; b=A2nmKFJxO7mjxdFWNxMZHU7rIExzdDryWdzXwM5knmfvSFHLrONrk5AKGEvoBKfWF LhUg5S/cQfVHiqXMgYQ8hiKEk8o5zLxbtMK6qwxHNpE/qWLdTXACZeEYxRoXERXrXB /t/t4dz1lZhvNXMlS5vARgQheOXGsANd0TAlaxGbtDQaEWcqGRe1q38kfBRi2RNWoP /11ripEQlAgJ3LoProhrbNj212E/Ip+XAoDtI3G8/eQDEKqwkbtKJscBI/996LYvfk zWBo2pGocmTw7LUHpSQ72+SAUX2lKA4yytPc4/Cugj58dTDvmEDnuTxC5KLBj5uv1W pz01d2yYQdroA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4CJXWT03MWz6tmK; Sat, 24 Oct 2020 22:19:32 +0200 (CEST) From: Alexandru-Sergiu Marton Date: Sun, 25 Oct 2020 02:19:39 +0300 Message-Id: <20201024231939.18693-1-brown121407@posteo.ro> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201020191738.30054-1-brown121407@posteo.ro> References: <20201020191738.30054-1-brown121407@posteo.ro> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: 1.0 (+) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=posteo.ro header.s=2017 header.b=A2nmKFJx; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.ro (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 5.09 X-TUID: 1Drz2gWPCvtt * gnu/services/web.scm (): 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. --- 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 b5061877e2..83e61aa374 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 @@ -23357,6 +23358,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 a74c6c54b4..69465d8ba6 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -14,6 +14,7 @@ ;;; Copyright © 2020 Tobias Geerinckx-Rice ;;; Copyright © 2020 Arun Isaac ;;; Copyright © 2020 Oleg Pykhalov +;;; Copyright © 2020 Alexandru-Sergiu Marton ;;; ;;; 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 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 + (($ 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)))) -- 2.28.0