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>
13 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
53 (uri (string-append "https://download.tuxfamily.org/chrony/"
54 "chrony-" version ".tar.gz"))
56 (base32 "0148bgzymdigkjs66fihrqw98g1yf6vgy40nlajqkw35m24sh3cx"))))
57 (build-system gnu-build-system)
59 `(#:modules ((srfi srfi-26)
61 (guix build gnu-build-system))
63 (list "--enable-scfilter"
64 "--with-sendmail=sendmail"
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.
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"))))))))
84 (list gnutls libcap libseccomp nettle))
85 (home-page "https://chrony.tuxfamily.org/")
86 (synopsis "System clock synchronisation service that speaks NTP")
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.
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.
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.
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.")
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")
118 "http://archive.ntp.org/ntp4/ntp-"
119 (version-major+minor version)
120 "/ntp-" version ".tar.gz")))
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
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")
132 "13d28sg45rflc7kqiv30asrhna8n69wlpwx16l65rravgpvp90h2")))
133 ;; And another one that fixes the build with glibc 2.34:
134 ;; <https://bugs.ntp.org/show_bug.cgi?id=3741>.
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")
142 "0z8ndaw3l086mbm42v9gfgxild1yvg0anxf3724lsalvgqlndcj4")))))
143 (modules '((guix build utils)))
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")
156 (native-inputs (list which pkg-config))
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))
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")
171 (modify-phases %standard-phases
172 (add-after 'unpack 'disable-network-test
174 (substitute* "tests/libntp/Makefile.in"
175 (("test-decodenetnum\\$\\(EXEEXT\\) ") ""))
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")))
186 (define-public openntpd
193 "mirror://openbsd/OpenNTPD/openntpd-" version ".tar.gz"))
196 "0ijsylc7a4jlpxsqa0jq1w1c7333id8pcakzl7a5749ria1xp0l5"))))
197 (build-system gnu-build-system)
200 (let* ((libressl (assoc-ref %build-inputs "libressl"))
201 (libressl-version ,(package-version
202 (car (assoc-ref (package-inputs this-package)
204 (list "--with-privsep-user=ntpd"
205 "--localstatedir=/var"
206 (string-append "--with-cacert=" libressl
207 "/share/libressl-" libressl-version
210 (modify-phases %standard-phases
211 (add-after 'unpack 'modify-install-locations
213 ;; Don't try to create /var/run or /var/db
214 (substitute* "src/Makefile.in"
215 (("DESTDIR\\)\\$\\(localstatedir") "TMPDIR"))
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.")
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))))