aboutsummaryrefslogtreecommitdiff
path: root/guix-module-dir
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-11-23 11:02:36 +0100
committerWojtek Kosior <koszko@koszko.org>2022-11-23 11:18:02 +0100
commit2b2c70932bf6ffcd77fbe5f6c59a203299f755a5 (patch)
tree5efca6171b7f7984612a5d7b6e0d63d9a89d9b25 /guix-module-dir
parent366d927d626065db29cdf4aeb92a2122683cdf73 (diff)
downloadhydrilla-website-2b2c70932bf6ffcd77fbe5f6c59a203299f755a5.tar.gz
hydrilla-website-2b2c70932bf6ffcd77fbe5f6c59a203299f755a5.zip
add WSGI script
Diffstat (limited to 'guix-module-dir')
-rw-r--r--guix-module-dir/hydrilla-website.scm32
1 files changed, 32 insertions, 0 deletions
diff --git a/guix-module-dir/hydrilla-website.scm b/guix-module-dir/hydrilla-website.scm
index af593bf..ce76784 100644
--- a/guix-module-dir/hydrilla-website.scm
+++ b/guix-module-dir/hydrilla-website.scm
@@ -57,6 +57,38 @@
;; checkout. We instead build from source tarball generated under ./dist/.
(local-file (string-append %source-dir "/dist/" source-tarball-name)))
(build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'replace-wsgi.py
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; In the wsgi.py file, embed the PYTHONPATH containing both the
+ ;; dependencies and the python modules of this package. This will
+ ;; make them available at runtime.
+ (let ((pythonpath
+ (string-append (getenv "GUIX_PYTHONPATH")
+ ":"
+ (site-packages inputs outputs))))
+ (substitute* "wsgi.py"
+ (("^from .* import .*" import-line)
+ (string-append
+ "# Make Guix-installed dependencies visible to Python.\n"
+ "import sys\n"
+ "sys.path.extend('" pythonpath "'.split(':'))\n"
+ "\n"
+ import-line))
+ (("^set_secret.*")
+ (string-append
+ "from pathlib import Path\n"
+ "path_to_secret = Path('/etc/hydrilla-website/secret.txt')\n"
+ "if path_to_secret.exists():\n"
+ " set_secret(path_to_secret.read_text().strip())"))))))
+ (add-after 'install 'install-wsgi-script
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (share-dir (string-append out "/share/hydrilla-website")))
+ (mkdir-p share-dir)
+ (copy-file "wsgi.py" (string-append share-dir "/wsgi.py"))))))))
(propagated-inputs
(list python-flask))
(native-inputs