blob: fbee5203342bfb341e890ab617096c137b590bfe (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
;; SPDX-License-Identifier: CC0-1.0
;; Copyright (C) 2022,2023 Wojtek Kosior <koszko@koszko.org>
;;
;; Available under the terms of Creative Commons Zero v1.0 Universal.
(define-module (hydrilla-base)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 regex)
#:use-module (guix build-system python)
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages check)
#:use-module (gnu packages license)
#:use-module (gnu packages python-build)
#:use-module (gnu packages python-check)
#:use-module (gnu packages python-web)
#:use-module (gnu packages python-xyz)
#:export (%source-dir
%pkg-info-path
%hydrilla-version
%source-tarball-name))
(define %source-dir
(let* ((this-file (search-path %load-path "hydrilla.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.egg-info/PKG-INFO"))
(define %hydrilla-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-" %hydrilla-version ".tar.gz"))
(define-public python-types-requests-2.26
(package
(name "python-types-requests")
(version "2.26.0")
(source (origin
(method url-fetch)
(uri (pypi-uri "types-requests" version))
(sha256
(base32
"10sq8jarr642vhw53k6zbf3hn2b8xfyrckwfngml4fj19g1whpnz"))))
(build-system python-build-system)
(home-page "https://github.com/python/typeshed")
(synopsis "Typing stubs for requests")
(description
"This package provides a collection of library stubs for Python, with
static types.")
(license license:asl2.0)))
(define-public hydrilla-without-haketilo
(package
(name "hydrilla-without-haketilo")
(version %hydrilla-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)
(arguments
`(#:modules ((ice-9 match)
(guix build utils)
(guix build python-build-system))
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'patch-requirements
(lambda _
(substitute* "setup.cfg"
(("^all = .*")
"all = flask>=1.1")
(("[ ]*haketilo = .*:.*" match)
(string-append "#" match)))))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(when tests?
(invoke "pytest"))))
(add-after 'wrap 'prevent-local-package-interference
(lambda* (#:key outputs #:allow-other-keys)
(match-let ((((_ . dir)) outputs))
(for-each (lambda (prog-name)
(substitute* (string-append dir "/bin/" prog-name)
(("^#!/.*$" shabang)
(string-append shabang
"export PYTHONNOUSERSITE=1\n"))))
'("hydrilla"
"hydrilla-server"
"hydrilla-builder"))))))))
(propagated-inputs
(list python-click
python-flask
python-immutables
python-jsonschema
reuse))
(native-inputs
(list python-setuptools-scm
python-babel
python-pytest
python-pypa-build
python-mypy
(module-ref (current-module) 'python-types-requests
python-types-requests-2.26)))
(home-page "https://hydrillabugs.koszko.org/projects/haketilo/wiki")
(synopsis "Block JavaScript and add custom logic to web pages")
(description "Haketilo HTTP proxy facilitates viewing of websites while
having their original JavaScript replaced by user-provided scripts. Haketilo
combines the functionalities of content blocker and user script manager. It can
be used with its script repository, Hydrilla.")
(license (list license:agpl3+ license:gpl3+ license:cc0))))
|