gnu: Add wlgreet.
[jackhill/guix/guix.git] / gnu / packages / ntp.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
5 ;;; Copyright © 2015, 2018 Ludovic Courtès <ludo@gnu.org>
6 ;;; Copyright © 2016, 2017, 2018, 2022 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
9 ;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
10 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
11 ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
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 ntp)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages autotools)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages libevent)
33 #:use-module (gnu packages linux)
34 #:use-module (gnu packages nettle)
35 #:use-module (gnu packages pkg-config)
36 #:use-module (gnu packages readline)
37 #:use-module (gnu packages tls)
38 #:use-module (guix build-system gnu)
39 #:use-module (guix download)
40 #:use-module (guix git-download)
41 #:use-module ((guix licenses) #:prefix l:)
42 #:use-module (guix packages)
43 #:use-module (guix utils)
44 #:use-module (srfi srfi-1))
45
46 (define-public chrony
47 (package
48 (name "chrony")
49 (version "4.3")
50 (source
51 (origin
52 (method url-fetch)
53 (uri (string-append "https://download.tuxfamily.org/chrony/"
54 "chrony-" version ".tar.gz"))
55 (sha256
56 (base32 "0148bgzymdigkjs66fihrqw98g1yf6vgy40nlajqkw35m24sh3cx"))))
57 (build-system gnu-build-system)
58 (arguments
59 `(#:modules ((srfi srfi-26)
60 (guix build utils)
61 (guix build gnu-build-system))
62 #:configure-flags
63 (list "--enable-scfilter"
64 "--with-sendmail=sendmail"
65 "--with-user=chrony")
66 #:phases
67 (modify-phases %standard-phases
68 (add-after 'unpack 'stay-inside-out
69 ;; Simply setting CHRONYVARDIR to something nonsensical at install
70 ;; time would result in nonsense file names in man pages.
71 (lambda _
72 (substitute* "Makefile.in"
73 (("mkdir -p \\$\\(DESTDIR\\)\\$\\(CHRONYVARDIR\\)") ":"))))
74 (add-after 'install 'install-more-documentation
75 (lambda* (#:key outputs #:allow-other-keys)
76 (let* ((out (assoc-ref outputs "out"))
77 (doc (string-append out "/share/doc/" ,name "-" ,version)))
78 (for-each (cut install-file <> doc)
79 (list "README" "FAQ"))
80 (copy-recursively "examples" (string-append doc "/examples"))))))))
81 (native-inputs
82 (list pkg-config))
83 (inputs
84 (list gnutls libcap libseccomp nettle))
85 (home-page "https://chrony.tuxfamily.org/")
86 (synopsis "System clock synchronisation service that speaks NTP")
87 (description
88 "Chrony keeps your system time accurate. It synchronises your computer's
89 clock with @acronym{NTP, Network Time Protocol} servers, reference clocks such
90 as GPS receivers, or even manual input of the correct time from a wristwatch.
91
92 Chrony will determine the rate at which the computer gains or loses time, and
93 compensate for it. It can also operate as an NTPv4 (RFC 5905) server and peer
94 to tell time to other computers on the network.
95
96 It's designed to perform well even under adverse conditions: congested
97 networks, unreliable clocks drifting with changes in temperature, and devices
98 or virtual machines that are frequently turned off and connect to the Internet
99 for only a few minutes at a time.
100
101 Typical accuracy when synchronised over the Internet is several milliseconds.
102 On a local network this can reach tens of microseconds. With hardware
103 time-stamping or reference clock, sub-microsecond accuracy is possible.")
104 (license l:gpl2)))
105
106 (define-public ntp
107 (package
108 (name "ntp")
109 (version "4.2.8p15")
110 (source
111 (origin
112 (method url-fetch)
113 (uri (list (string-append
114 "https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-"
115 (version-major+minor version)
116 "/ntp-" version ".tar.gz")
117 (string-append
118 "http://archive.ntp.org/ntp4/ntp-"
119 (version-major+minor version)
120 "/ntp-" version ".tar.gz")))
121 (sha256
122 (base32 "06cwhimm71safmwvp6nhxp6hvxsg62whnbgbgiflsqb8mgg40n7n"))
123 ;; Add an upstream patch to fix build with GCC 10. Taken from
124 ;; <https://bugs.ntp.org/show_bug.cgi?id=3688>.
125 (patches (list (origin
126 (method url-fetch)
127 (uri "https://bugs.ntp.org/attachment.cgi?id=1760\
128 &action=diff&context=patch&collapsed=&headers=1&format=raw")
129 (file-name "ntp-gcc-compat.patch")
130 (sha256
131 (base32
132 "13d28sg45rflc7kqiv30asrhna8n69wlpwx16l65rravgpvp90h2")))
133 ;; And another one that fixes the build with glibc 2.34:
134 ;; <https://bugs.ntp.org/show_bug.cgi?id=3741>.
135 (origin
136 (method url-fetch)
137 (uri "https://bugs.ntp.org/attachment.cgi?id=1814\
138 &action=diff&collapsed=&headers=1&format=raw")
139 (file-name "ntp-glibc-compat.patch")
140 (sha256
141 (base32
142 "0z8ndaw3l086mbm42v9gfgxild1yvg0anxf3724lsalvgqlndcj4")))))
143 (modules '((guix build utils)))
144 (snippet
145 '(begin
146 ;; Remove the bundled copy of libevent, but we must keep
147 ;; sntp/libevent/build-aux since configure.ac contains
148 ;; AC_CONFIG_AUX_DIR([sntp/libevent/build-aux])
149 (rename-file "sntp/libevent/build-aux"
150 "sntp/libevent:build-aux")
151 (delete-file-recursively "sntp/libevent")
152 (mkdir "sntp/libevent")
153 (rename-file "sntp/libevent:build-aux"
154 "sntp/libevent/build-aux")
155 #t))))
156 (native-inputs (list which pkg-config))
157 (inputs
158 `(("openssl" ,openssl-1.1)
159 ("libevent" ,libevent)
160 ;; Build with POSIX capabilities support on GNU/Linux. This allows 'ntpd'
161 ;; to run as non-root (when invoked with '-u'.)
162 ,@(if (string-suffix? "-linux"
163 (or (%current-target-system) (%current-system)))
164 `(("libcap" ,libcap))
165 '())))
166 (arguments
167 `(;; Pass "--with-yielding-select=yes" so that 'configure' knows whether
168 ;; 'select' yields when using pthreads in a cross-compilation context.
169 #:configure-flags (list "--with-yielding-select=yes")
170 #:phases
171 (modify-phases %standard-phases
172 (add-after 'unpack 'disable-network-test
173 (lambda _
174 (substitute* "tests/libntp/Makefile.in"
175 (("test-decodenetnum\\$\\(EXEEXT\\) ") ""))
176 #t)))))
177 (build-system gnu-build-system)
178 (synopsis "Real time clock synchronization system")
179 (description "NTP is a system designed to synchronize the clocks of
180 computers over a network.")
181 (license (l:x11-style
182 "https://www.eecis.udel.edu/~mills/ntp/html/copyright.html"
183 "A non-copyleft free licence from the University of Delaware"))
184 (home-page "https://www.ntp.org")))
185
186 (define-public openntpd
187 (package
188 (name "openntpd")
189 (version "6.8p1")
190 (source (origin
191 (method url-fetch)
192 (uri (string-append
193 "mirror://openbsd/OpenNTPD/openntpd-" version ".tar.gz"))
194 (sha256
195 (base32
196 "0ijsylc7a4jlpxsqa0jq1w1c7333id8pcakzl7a5749ria1xp0l5"))))
197 (build-system gnu-build-system)
198 (arguments
199 `(#:configure-flags
200 (let* ((libressl (assoc-ref %build-inputs "libressl"))
201 (libressl-version ,(package-version
202 (car (assoc-ref (package-inputs this-package)
203 "libressl")))))
204 (list "--with-privsep-user=ntpd"
205 "--localstatedir=/var"
206 (string-append "--with-cacert=" libressl
207 "/share/libressl-" libressl-version
208 "/cert.pem")))
209 #:phases
210 (modify-phases %standard-phases
211 (add-after 'unpack 'modify-install-locations
212 (lambda _
213 ;; Don't try to create /var/run or /var/db
214 (substitute* "src/Makefile.in"
215 (("DESTDIR\\)\\$\\(localstatedir") "TMPDIR"))
216 #t)))))
217 (inputs
218 (list libressl)) ; enable TLS time constraints. See ntpd.conf(5).
219 (home-page "http://www.openntpd.org/")
220 (synopsis "NTP client and server by the OpenBSD Project")
221 (description "OpenNTPD is the OpenBSD Project's implementation of a client
222 and server for the Network Time Protocol. Its design goals include being
223 secure, easy to configure, and accurate enough for most purposes, so it's more
224 minimalist than ntpd.")
225 (properties
226 '((release-monitoring-url . "https://cdn.openbsd.org/pub/OpenBSD/OpenNTPD")))
227 ;; A few of the source files are under bsd-3.
228 (license (list l:isc l:bsd-3))))