summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2023-07-25 20:43:08 +0100
committerArun Isaac2023-07-25 23:39:14 +0100
commit208bb4e42fdcf3335b454d6f8bc7b19c4c3292b3 (patch)
treee364f6dc1d0ebf7cea166b1677cdca1854df69a4
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.
-rw-r--r--doc/forge.skb7
-rw-r--r--guix/forge/klaus.scm29
2 files changed, 33 insertions, 3 deletions
diff --git a/doc/forge.skb b/doc/forge.skb
index e11b255..5c5a5fd 100644
--- a/doc/forge.skb
+++ b/doc/forge.skb
@@ -36,7 +36,9 @@ email.])
     (p [guix-forge integrates the following software components:]
        (itemize
         (item [,(ref :url "https://laminar.ohwg.net/" :text "laminar")
-for continuous integration])))
+for continuous integration])
+        (item [,(ref :url "https://github.com/jonashaag/klaus/" :text
+"klaus") to serve project git repositories on the web])))
     (p [In the future, it will also provide:]
        (itemize
         (item [web server to serve static project sites])
@@ -299,4 +301,5 @@ gunicorn is run in.]))
          [Identifier of the webhook. This hook is triggered at ,(ref
 :url [http://host:port/hooks/<id>]).])
        (record-field "run"
-         [G-expression to run when the webhook is triggered])))))
+         [G-expression to run when the webhook is triggered]))
+     (docstring-function-documentation "guix/forge/klaus.scm" 'klaus-gunicorn-app))))
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))))))