projects/guix·blob javascript-team · refs

227 lines · 10.3 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 Petter <[email protected]>
3;;; Copyright © 2016-2021, 2024 Leo Famulari <[email protected]>
4;;; Copyright © 2020 Tobias Geerinckx-Rice <[email protected]>
5;;; Copyright © 2020-2022, 2026 Efraim Flashner <[email protected]>
6;;; Copyright © 2020 Giacomo Leidi <[email protected]>
7;;; Copyright © 2021 Maxim Cournoyer <[email protected]>
8;;; Copyright © 2021 Arun Isaac <[email protected]>
9;;; Copyright © 2022 John Kehayias <[email protected]>
10;;; Copyright © 2023 Benjamin Slade <[email protected]>
11;;; Copyright © 2024 David Pflug <[email protected]>
12;;;
13;;; This file is part of GNU Guix.
14;;;
15;;; GNU Guix is free software; you can redistribute it and/or modify it
16;;; under the terms of the GNU General Public License as published by
17;;; the Free Software Foundation; either version 3 of the License, or (at
18;;; your option) any later version.
19;;;
20;;; GNU Guix is distributed in the hope that it will be useful, but
21;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23;;; GNU General Public License for more details.
24;;;
25;;; You should have received a copy of the GNU General Public License
26;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28(define-module (gnu packages syncthing)
29 #:use-module (guix build-system go)
30 #:use-module (guix build-system pyproject)
31 #:use-module (guix gexp)
32 #:use-module (guix packages)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix licenses)
36 #:use-module (gnu packages)
37 #:use-module (gnu packages bash)
38 #:use-module (gnu packages freedesktop)
39 #:use-module (gnu packages glib)
40 #:use-module (gnu packages gnome)
41 #:use-module (gnu packages golang)
42 #:use-module (gnu packages golang-build)
43 #:use-module (gnu packages golang-compression)
44 #:use-module (gnu packages gtk)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages python-crypto)
47 #:use-module (gnu packages python-build)
48 #:use-module (gnu packages time))
49
50(define-public syncthing
51 (package
52 (name "syncthing")
53 ;; XXX: During update, refresh the service configuration if the new
54 ;; release includes a migration, see:
55 ;; <https://docs.syncthing.net/users/config.html>,
56 ;; <https://github.com/syncthing/syncthing/blob/main/lib/config/migrations.go>.
57 (version "2.1.2")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append "https://github.com/syncthing/syncthing"
61 "/releases/download/v" version
62 "/syncthing-source-v" version ".tar.gz"))
63 (sha256
64 (base32
65 "13k73wlmhxgwrzxf5dwb526dw8c5zw5s2jv29cn9lnvhgkmn2hjq"))))
66 ;; TODO: Build from git, remove vendor.
67 (build-system go-build-system)
68 ;; The primary Syncthing executable goes to "out", while the auxiliary
69 ;; server programs and utility tools go to "utils". This reduces the size
70 ;; of "out" by ~144 MiB.
71 (outputs '("out" "utils"))
72 (arguments
73 (list
74 #:modules '((srfi srfi-26) ; for cut
75 (guix build utils)
76 (guix build go-build-system))
77 #:import-path "github.com/syncthing/syncthing"
78 ;; Check 'go.mod' in the source distribution for the required version of Go.
79 ;; We don't need to install the source code for end-user applications.
80 #:install-source? #f
81 #:phases
82 #~(modify-phases %standard-phases
83 (add-before 'build 'increase-test-timeout
84 (lambda _
85 (substitute* "src/github.com/syncthing/syncthing/build.go"
86 (("120s") "999s"))))
87
88 (replace 'build
89 (lambda _
90 (with-directory-excursion "src/github.com/syncthing/syncthing"
91 ; Build the primary Syncthing executable
92 (invoke "go" "run" "build.go" "-no-upgrade" "build" "syncthing")
93 ; Build utilities used to run an independent Syncthing network
94 (for-each (cut invoke "go" "run" "build.go" "build" <>)
95 '("stcrashreceiver" "strelaypoolsrv" "stupgrades"
96 "strelaysrv" "stdiscosrv" "ursrv")))))
97
98 (replace 'check
99 (lambda* (#:key tests? #:allow-other-keys)
100 (when tests?
101 (with-directory-excursion "src/github.com/syncthing/syncthing"
102 (invoke "go" "run" "build.go" "test")))))
103
104 (replace 'install
105 (lambda _
106 (with-directory-excursion "src/github.com/syncthing/syncthing"
107 (install-file "syncthing" (string-append #$output "/bin"))
108 (for-each (cut install-file <> (string-append #$output:utils "/bin/"))
109 '("stdiscosrv" "strelaysrv" "ursrv" "stupgrades"
110 "strelaypoolsrv" "stcrashreceiver")))))
111
112 (add-after 'install 'install-docs
113 (lambda _
114 (let ((man (string-append #$output "/share/man"))
115 (man:utils (string-append #$output:utils "/share/man")))
116 ;; Install all the man pages to "out".
117 (for-each
118 (lambda (file)
119 (install-file file
120 (string-append man "/man" (string-take-right file 1))))
121 (find-files "src/github.com/syncthing/syncthing/man" "\\.[1-9]"))
122 ;; Copy all the man pages to "utils"
123 (copy-recursively man man:utils)
124 ;; Delete extraneous man pages from "out" and "utils",
125 ;; respectively.
126 (delete-file (string-append man "/man1/stdiscosrv.1"))
127 (delete-file (string-append man "/man1/strelaysrv.1"))
128 (delete-file (string-append man:utils "/man1/syncthing.1"))))))))
129 (synopsis "Decentralized continuous file system synchronization")
130 (description "Syncthing is a peer-to-peer file synchronization tool that
131supports a wide variety of computing platforms. It uses the Block Exchange
132Protocol.")
133 (home-page "https://github.com/syncthing/syncthing")
134 (properties
135 '((release-monitoring-url . "https://syncthing.net/downloads/")
136 (upstream-name . "syncthing-source")
137 ;; The hashing code greatly benefits from newer architecture support.
138 (tunable? . #t)))
139 (license mpl2.0)))
140
141(define-public syncthing-gtk
142 ;; The commit used below corresponds to the latest commit of the Python 3
143 ;; fork maintained by Debian. Upstream hasn't bothered porting to Python 3
144 ;; (see: https://github.com/kozec/syncthing-gtk/issues/487).
145 (let ((revision "2")
146 (commit "1e84f332e413ba123bcd443443ffc2b435ffafd2"))
147 (package
148 (name "syncthing-gtk")
149 (version (git-version "0.9.4.4" revision commit))
150 (source (origin
151 (method git-fetch)
152 (uri (git-reference
153 (url "https://salsa.debian.org/debian/syncthing-gtk.git")
154 (commit commit)))
155 (file-name (git-file-name name version))
156 (sha256
157 (base32
158 "1b77rdmx74zyz3lfhzzvdf3rrm7lfc7246varnr5xi366z3410ha"))))
159 (build-system pyproject-build-system)
160 (arguments
161 (list
162 #:tests? #f ;has no tests
163 #:phases
164 #~(modify-phases %standard-phases
165 (add-after 'unpack 'hardcode-dependencies
166 (lambda* (#:key inputs #:allow-other-keys)
167 (let ((psmisc (assoc-ref inputs "psmisc"))
168 (syncthing (assoc-ref inputs "syncthing")))
169 ;; Hardcode dependencies paths to avoid propagation.
170 (substitute* "syncthing_gtk/tools.py"
171 (("killall") (string-append psmisc "/bin/killall")))
172 (substitute* "syncthing_gtk/configuration.py"
173 (("/usr/bin/syncthing") (string-append syncthing
174 "/bin/syncthing"))))))
175 (add-after 'unpack 'fix-autostart-path
176 ;; Change the autostart .desktop file 'Exec' command so it finds
177 ;; the Python wrapper of 'syncthing-gtk', rather than the unwrapped
178 ;; '.syncthing-gtk-real'.
179 (lambda _
180 (substitute* "syncthing_gtk/tools.py"
181 (("return executable")
182 "return \"syncthing-gtk\""))
183 ;; Prevent complaints from 'pip3 check':
184 ;; DEPRECATION: syncthing-gtk unknown has a non-standard
185 ;; version number. pip 24.1 will enforce this behaviour change.
186 (substitute* "setup.py"
187 (("return version")
188 (string-append
189 "return \"" (car (string-split #$version #\-)) "\"")))))
190 (add-after 'unpack 'remove-windows.py
191 (lambda _
192 ;; A Windows-specific module that fails to load with
193 ;; "ModuleNotFoundError: No module named 'msvcrt'.
194 (delete-file "syncthing_gtk/windows.py")))
195 (add-after 'wrap 'wrap-libs
196 (lambda* (#:key outputs #:allow-other-keys)
197 (let ((out (assoc-ref outputs "out")))
198 (wrap-program (string-append out "/bin/syncthing-gtk")
199 `("GUIX_GDK_PIXBUF_MODULE_FILES" ":" suffix
200 (,(getenv "GUIX_GDK_PIXBUF_MODULE_FILES")))
201 `("GI_TYPELIB_PATH" ":" suffix
202 (,(getenv "GI_TYPELIB_PATH"))))))))))
203 (native-inputs (list python-setuptools))
204 (inputs
205 (list bash-minimal
206 gtk+
207 libappindicator
208 libnotify
209 python-bcrypt
210 python-dateutil
211 python-pycairo
212 python-pygobject-3.50
213 psmisc
214 syncthing))
215 (home-page "https://github.com/kozec/syncthing-gtk")
216 (synopsis "GTK3 based GUI and notification area icon for Syncthing")
217 (description "@code{syncthing-gtk} is a GTK3 Python based GUI and
218notification area icon for Syncthing. Supported Syncthing features:
219
220@itemize
221@item Everything that WebUI can display
222@item Adding, editing and deleting nodes
223@item Adding, editing and deleting repositories
224@item Restart, shutdown server
225@item Editing daemon settings
226@end itemize\n")
227 (license gpl2))))