;;; guix-forge --- Guix software forge meta-service ;;; Copyright © 2023–2025 Arun Isaac ;;; Copyright © 2024 jgart ;;; ;;; This file is part of guix-forge. ;;; ;;; guix-forge is free software: you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published ;;; by the Free Software Foundation, either version 3 of the License, ;;; or (at your option) any later version. ;;; ;;; guix-forge is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with guix-forge. If not, see ;;; . (define-module (forge klaus) #:use-module (forge environment) #:use-module ((forge git) #:select (git-without-safe-directory-check)) #:use-module (forge gunicorn) #:use-module (forge socket) #:use-module ((gnu packages version-control) #:select (python-klaus) #:prefix guix:) #:use-module (gnu system file-systems) #:use-module (guix packages) #:export (klaus-gunicorn-app)) (define-public python-klaus (package (inherit guix:python-klaus) (inputs ;; We use klaus to serve shared repositories. But, git's safe directory ;; check does not permit us to use shared repositories. Disable it. The ;; more long term solution is to rewrite klaus to not use the git CLI at ;; all. See https://github.com/jonashaag/klaus/issues/322 (modify-inputs (package-inputs guix:python-klaus) (replace "git" git-without-safe-directory-check))))) (define* (klaus-gunicorn-app repository-directory #:key (klaus python-klaus) (sockets (list (forge-unix-socket (path "/var/run/gunicorn/klaus/socket")))) site-name) "Return a @code{} object to deploy klaus. @var{repository-directory} is the path to the directory containing git repositories to serve. @var{klaus} is the klaus package to use. @var{sockets} is a list of @code{} or @code{} objects describing sockets to listen on. @var{site-name} is the name of the klaus site to be displayed in the banner." (gunicorn-app (name "klaus") (package klaus) (wsgi-app-module "klaus.contrib.wsgi_autoreload") (sockets sockets) (environment-variables (cons (environment-variable (name "KLAUS_REPOS_ROOT") (value repository-directory)) (if site-name (list (environment-variable (name "KLAUS_SITE_NAME") (value site-name))) (list)))) (mappings (list (file-system-mapping (source repository-directory) (target source))))))