about summary refs log tree commit diff
path: root/guix
diff options
context:
space:
mode:
authorArun Isaac2023-07-25 20:43:08 +0100
committerArun Isaac2023-07-25 23:39:14 +0100
commit208bb4e42fdcf3335b454d6f8bc7b19c4c3292b3 (patch)
treee364f6dc1d0ebf7cea166b1677cdca1854df69a4 /guix
parentf1e30047af67ae6a1827c625c0327609976c1d1d (diff)
downloadguix-forge-208bb4e42fdcf3335b454d6f8bc7b19c4c3292b3.tar.gz
guix-forge-208bb4e42fdcf3335b454d6f8bc7b19c4c3292b3.tar.lz
guix-forge-208bb4e42fdcf3335b454d6f8bc7b19c4c3292b3.zip
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.
Diffstat (limited to 'guix')
-rw-r--r--guix/forge/klaus.scm29
1 files changed, 28 insertions, 1 deletions
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 @@
 ;;; <https://www.gnu.org/licenses/>.
 
 (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{<gunicorn-app>} object to deploy klaus on
+@var{sockets}, a list of @code{<forge-ip-socket>} or
+@code{<forge-unix-socket>} 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))))))