From 208bb4e42fdcf3335b454d6f8bc7b19c4c3292b3 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Tue, 25 Jul 2023 20:43:08 +0100
Subject: klaus: Add helper function to create klaus gunicorn app.
* guix/forge/klaus.scm: Import (forge gunicorn) and (gnu system
file-systems).
(klaus-gunicorn-app): New public function.
* doc/forge.skb (Introduction): Advertise klaus support.
(Reference): Document klaus-gunicorn-app.
---
guix/forge/klaus.scm | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
(limited to 'guix')
diff --git a/guix/forge/klaus.scm b/guix/forge/klaus.scm
index ba963ee..54b374f 100644
--- a/guix/forge/klaus.scm
+++ b/guix/forge/klaus.scm
@@ -18,19 +18,22 @@
;;; .
(define-module (forge klaus)
+ #:use-module (forge gunicorn)
#:use-module ((gnu packages check) #:select (python-nose python-pytest))
#:use-module ((gnu packages python-web)
#:select (python-flask python-werkzeug))
#:use-module ((gnu packages python-xyz)
#:select (python-dulwich python-humanize python-pygments))
#:use-module ((gnu packages version-control) #:select (git-minimal))
+ #:use-module (gnu system file-systems)
#:use-module (guix build-system pyproject)
#:use-module (guix build-system python)
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
- #:use-module (guix utils))
+ #:use-module (guix utils)
+ #:export (klaus-gunicorn-app))
(define-public python-httpauth
(package
@@ -117,3 +120,27 @@ routes using HTTP Digest Authentication.")
@item Code navigation using Exuberant ctags
@end itemize")
(license license:isc)))
+
+(define* (klaus-gunicorn-app repository-directory sockets
+ #:key site-name)
+ "Return a @code{} object to deploy klaus on
+@var{sockets}, a list of @code{} or
+@code{} objects.
+
+@var{repository-directory} is the path to the directory containing git
+repositories to serve.
+
+@var{site-name} is the name of the klaus site to be displayed in the
+banner."
+ (gunicorn-app
+ (name "klaus")
+ (package python-klaus)
+ (wsgi-app-module "klaus.contrib.wsgi_autoreload")
+ (sockets sockets)
+ (environment-variables `(("KLAUS_REPOS_ROOT" . ,repository-directory)
+ ,@(if site-name
+ `(("KLAUS_SITE_NAME" . ,site-name))
+ '())))
+ (mappings (list (file-system-mapping
+ (source repository-directory)
+ (target source))))))
--
cgit v1.2.3