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
| | ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages syncthing)
#:use-module (guix build-system gnu)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix licenses)
#:use-module (guix packages)
#:use-module (gnu packages golang))
(define-public syncthing
(package
(name "syncthing")
(version "v0.13.10")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/syncthing/syncthing.git")
(commit version)))
(file-name (string-append name "-" version))
(sha256
(base32
"07q3j6mnrza719rnvbkdsmvlkyr2pch5sj2l204m5iy5mxaghpx7"))))
;; TODO Make go-build-system.
(build-system gnu-build-system)
(arguments
`(#:phases
(modify-phases %standard-phases
(delete 'configure) ; No ./configure script.
;; This is the directory structure recommended by Syncthings "guide to
;; building": https://docs.syncthing.net/dev/building.html
;; Can we simplify this step?
(replace 'unpack
(lambda* (#:key source #:allow-other-keys)
(let ((tree "src/github.com/syncthing/syncthing"))
(copy-recursively source tree))))
(add-after 'unpack 'set-env
(lambda* (#:key inputs outputs #:allow-other-keys)
(let ((source (assoc-ref inputs "source")))
(setenv "GOPATH" (getcwd))
;; This should control where `go run build.go install` installs
;; things, but it seems to have no effect in this case.
(setenv "GOBIN" (assoc-ref outputs "out"))
;; Enable use of bundled dependencies. This is a stop-gap
;; until the dependencies are packaged properly.
(setenv "GO15VENDOREXPERIMENT" "1"))))
;; This is related to the unpack phase. Can it be avoided?
(add-before 'build 'chdir
(lambda _ (chdir "src/github.com/syncthing/syncthing")))
(replace 'build
(lambda _
(zero? (system* "go" "run" "build.go"
;; Disable Syncthing's built-in updater.
"-no-upgrade"
;; This might not be necessary if building from a
;; tarball.
"-version" ,version))))
(replace 'check
(lambda _
(zero? (system* "go" "run" "build.go" "test"))))
;; TODO Make this use `go run build.go install`.
(replace 'install
(lambda _
(copy-recursively "bin" (string-append (assoc-ref %outputs "out")
"/bin"))))
;; TODO These man pages are generated from a different Git
;; repo, https://github.com/syncthing/docs.
(add-after 'install 'install-doc
(lambda* (#:key outputs source #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(man1 (string-append out "/share/man/man1"))
(man5 (string-append out "/share/man/man5"))
(man7 (string-append out "/share/man/man7"))
(src (string-append source "/man/")))
(install-file (string-append src "syncthing.1") man1)
(install-file (string-append src "syncthing-config.5") man5)
(install-file (string-append src "syncthing-stignore.5") man5)
(install-file (string-append src "syncthing-bep.7") man7)
(install-file (string-append src "syncthing-device-ids.7") man7)
(install-file (string-append src "syncthing-event-api.7") man7)
(install-file (string-append src "syncthing-faq.7") man7)
(install-file (string-append src "syncthing-globaldisco.7") man7)
(install-file (string-append src "syncthing-localdisco.7") man7)
(install-file (string-append src "syncthing-networking.7") man7)
(install-file (string-append src "syncthing-relay.7") man7)
(install-file (string-append src "syncthing-rest-api.7") man7)
(install-file (string-append src "syncthing-security.7") man7)
(install-file (string-append src "syncthing-versioning.7") man7)
(install-file (string-append src "syncthing.1") man7)
#t))))))
(native-inputs
`(("go" ,go-1.5)))
(synopsis "Decentralized filesystem synchronization")
(description "Syncthing is a peer-to-peer file synchronization tool that
supports a wide variety of computing platforms. It uses the Block Exchange
Protocol.")
(home-page "https://syncthing.net")
;; TODO Either delete the bundled dependencies or list their licenses here.
(license mpl2.0)))
|