diff options
Diffstat (limited to 'guix-module-dir')
-rw-r--r-- | guix-module-dir/hydrilla-website.scm | 32 |
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 |