From 366d927d626065db29cdf4aeb92a2122683cdf73 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 22 Nov 2022 21:51:37 +0100 Subject: move Guix packaging to a module --- guix-module-dir/hydrilla-website.scm | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 guix-module-dir/hydrilla-website.scm (limited to 'guix-module-dir') diff --git a/guix-module-dir/hydrilla-website.scm b/guix-module-dir/hydrilla-website.scm new file mode 100644 index 0000000..af593bf --- /dev/null +++ b/guix-module-dir/hydrilla-website.scm @@ -0,0 +1,71 @@ +;; SPDX-License-Identifier: CC0-1.0 + +;; Copyright (C) 2022 Wojtek Kosior +;; +;; Available under the terms of Creative Commons Zero v1.0 Universal. + +(define-module (hydrilla-website)) + +(use-modules + (ice-9 rdelim) + (ice-9 regex)) + +(define %source-dir + (let* ((this-file (search-path %load-path "hydrilla-website.scm")) + (proj-dir (dirname (dirname this-file)))) + (if (absolute-file-name? proj-dir) + proj-dir + (string-append (getcwd) "/" proj-dir)))) + +;; The PKG-INFO file is generated when running `python3 -m build -s` or similar. +;; It is also automatically included in the source release tarballs. +(define %pkg-info-path + (string-append %source-dir "/src/hydrilla_website.egg-info/PKG-INFO")) + +(define %website-version + (if (access? %pkg-info-path R_OK) + (call-with-input-file %pkg-info-path + (lambda (port) + (let ((process-line + (lambda (self-ref) + (let ((match-result + (string-match "^Version: (.*)" (read-line port)))) + (if match-result (match:substring match-result 1) + (self-ref self-ref)))))) + (process-line process-line)))) + "unknown")) + +(define source-tarball-name + (string-append "hydrilla_website-" %website-version ".tar.gz")) + +(use-modules + (guix packages) + (guix gexp) + (guix build-system python) + ((guix licenses) #:prefix license:) + (gnu packages python-build) + (gnu packages python-web) + (gnu packages python-xyz) + (gnu packages python-check)) + +(define-public hydrilla-website + (package + (name "hydrilla-website") + (version %website-version) + (source + ;; setuptools_scm makes it impossible to build directly from git + ;; 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) + (propagated-inputs + (list python-flask)) + (native-inputs + (list python-setuptools-scm + python-babel + python-pypa-build + python-mypy)) + (home-page "https://git.koszko.org/hydrilla-website") + (synopsis "Website for Haketilo & Hydrilla") + (description "This is the packaging of the website of Haketilo, a content +blocker + user script manager and Hydrilla, its script repository.") + (license (list license:agpl3+ license:gpl3+ license:cc0)))) -- cgit v1.2.3