diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-11-25 09:13:11 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-11-25 09:13:11 +0100 |
commit | b7a8611707d393abd6857c8f7986f66a1ea906ab (patch) | |
tree | e6c56cfa503b3c78229bc5206370721dda77a25c /container.scm | |
parent | 28ba79385cd1b80a99629d35bd535adc5f817497 (diff) | |
download | koszko-org-server-b7a8611707d393abd6857c8f7986f66a1ea906ab.tar.gz koszko-org-server-b7a8611707d393abd6857c8f7986f66a1ea906ab.zip |
add hydrilla.koszko.org virtualhost
Diffstat (limited to 'container.scm')
-rw-r--r-- | container.scm | 77 |
1 files changed, 73 insertions, 4 deletions
diff --git a/container.scm b/container.scm index c50a75b..39163d9 100644 --- a/container.scm +++ b/container.scm @@ -4,13 +4,25 @@ ;; ;; Available under the terms of Creative Commons Zero v1.0 Universal. -(use-modules (gnu)) -(use-modules (koszko-org-website)) -(use-modules (hydrilla-website)) +(use-modules (gnu) + (koszko-org-website) + (hydrilla-website) + (hydrilla-json-schemas) + (hydrilla) + ;; The following 4 are needed to construct GUIX_PYTHONPATH for + ;; Hydrilla WSGI scripts. + (guix build-system python) + (guix packages) + (guix search-paths) + (guix modules)) (use-package-modules web) +(use-package-modules python) (use-service-modules web) (use-service-modules shepherd) +(define %here + (getcwd)) + (define* (simple-wsgi-alias-gexp package wsgi-path #:key (aliased-path "/")) #~(let* ((wsgi-file (string-append #$package #$wsgi-path))) (format #f @@ -102,6 +114,62 @@ (simple-wsgi-alias-gexp hydrilla-website "/share/hydrilla-website/wsgi.py")))) +(define %python-path-spec-sexp + (search-path-specification->sexp + (guix-pythonpath-search-path (package-version (default-python))))) + +(define %hydrilla-pythonpath-inputs + (cons hydrilla (map cadr (package-transitive-target-inputs hydrilla)))) + +(define %hydrilla-pythonpath-gexp + (with-imported-modules (source-module-closure '((guix search-paths))) + #~(begin + (use-modules (guix search-paths)) + (let ((evaluated-list (evaluate-search-paths + (list (sexp->search-path-specification + '#$%python-path-spec-sexp)) + '#$%hydrilla-pythonpath-inputs))) + (cdar evaluated-list))))) + +(define %hydrilla-wsgi-regex + "^/api_v[^/]+/((resource|mapping)/[^/]+[.]json|query|list_all)$") + +(define %hydrilla-virtualhost + (httpd-virtualhost + "*:80" + (list "\ + ServerName hydrilla.koszko.org + ServerAlias www.hydrilla.koszko.org + ServerAdmin koszko@koszko.org + + <If \"%{HTTP_HOST} != 'hydrilla.koszko.org'\"> + Redirect permanent / http://hydrilla.koszko.org/ + </If> + " + #~(format #f "Alias /schemas ~a\n" + (string-append #$hydrilla-json-schemas + "/share/hydrilla-json-schemas")) + "\ + + DocumentRoot /var/lib/hydrilla/malcontent_dirs + <Location ~ \"^/api_v[^/]+/(resource|mapping)/\"> + ForceType application/json + </Location> + + WSGIScriptReloading On + " + (format #f "SetEnvIf Request_URI ~s MALCONENT_DIR=~a\n" + "^/(api_v[0-9]+)/" + "/var/lib/hydrilla/malcontent_dirs/$1") + #~(format #f "SetEnvIf Request_URI ~s HYDRILLA_GUIX_PYTHONPATH=~a\n" + "^/api_v[0-9]+/" + #$%hydrilla-pythonpath-gexp) + #~(format #f "WSGIScriptAliasMatch ~s ~a\n" + #$%hydrilla-wsgi-regex + (string-append + #$(local-file (string-append %here "/hydrilla-wsgi.py")) + "/$1"))))) + (define %wsgi-module (httpd-module (name "wsgi_module") @@ -168,7 +236,8 @@ %koszkonutek-tmp-virtualhost %hydrillabugs-virtualhost %hachettebugs-virtualhost - %haketilo-virtualhost)) + %haketilo-virtualhost + %hydrilla-virtualhost)) (service (shepherd-service-type 'dummy-network |