ntp.scm 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 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. ;;;
  12. ;;; This file is part of GNU Guix.
  13. ;;;
  14. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  15. ;;; under the terms of the GNU General Public License as published by
  16. ;;; the Free Software Foundation; either version 3 of the License, or (at
  17. ;;; your option) any later version.
  18. ;;;
  19. ;;; GNU Guix is distributed in the hope that it will be useful, but
  20. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;;; GNU General Public License for more details.
  23. ;;;
  24. ;;; You should have received a copy of the GNU General Public License
  25. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  26. (define-module (gnu packages ntp)
  27. #:use-module (gnu packages)
  28. #:use-module (gnu packages autotools)
  29. #:use-module (gnu packages base)
  30. #:use-module (gnu packages libevent)
  31. #:use-module (gnu packages linux)
  32. #:use-module (gnu packages nettle)
  33. #:use-module (gnu packages pkg-config)
  34. #:use-module (gnu packages readline)
  35. #:use-module (gnu packages tls)
  36. #:use-module (guix build-system gnu)
  37. #:use-module (guix download)
  38. #:use-module (guix git-download)
  39. #:use-module ((guix licenses) #:prefix l:)
  40. #:use-module (guix packages)
  41. #:use-module (guix utils)
  42. #:use-module (srfi srfi-1))
  43. (define-public chrony
  44. (package
  45. (name "chrony")
  46. (version "4.1")
  47. (source
  48. (origin
  49. (method url-fetch)
  50. (uri (string-append "https://download.tuxfamily.org/chrony/"
  51. "chrony-" version ".tar.gz"))
  52. (sha256
  53. (base32 "0k0nf5qqzl01106lkmwc32n6a1fxagalpbci38iccyilz79z4xpd"))))
  54. (build-system gnu-build-system)
  55. (arguments
  56. `(#:modules ((srfi srfi-26)
  57. (guix build utils)
  58. (guix build gnu-build-system))
  59. #:configure-flags
  60. (list "--enable-scfilter"
  61. "--with-sendmail=sendmail"
  62. "--with-user=chrony")
  63. #:phases
  64. (modify-phases %standard-phases
  65. (add-after 'unpack 'stay-inside-out
  66. ;; Simply setting CHRONYVARDIR to something nonsensical at install
  67. ;; time would result in nonsense file names in man pages.
  68. (lambda _
  69. (substitute* "Makefile.in"
  70. (("mkdir -p \\$\\(DESTDIR\\)\\$\\(CHRONYVARDIR\\)") ":"))
  71. #t))
  72. (add-after 'install 'install-more-documentation
  73. (lambda* (#:key outputs #:allow-other-keys)
  74. (let* ((out (assoc-ref outputs "out"))
  75. (doc (string-append out "/share/doc/" ,name "-" ,version)))
  76. (for-each (cut install-file <> doc)
  77. (list "README" "FAQ"))
  78. (copy-recursively "examples" (string-append doc "/examples"))
  79. #t))))))
  80. (native-inputs
  81. `(("pkg-config" ,pkg-config)))
  82. (inputs
  83. `(("gnutls" ,gnutls)
  84. ("libcap" ,libcap)
  85. ("libseccomp" ,libseccomp)
  86. ("nettle" ,nettle)))
  87. (home-page "https://chrony.tuxfamily.org/")
  88. (synopsis "System clock synchronisation service that speaks NTP")
  89. (description
  90. "Chrony keeps your system time accurate. It synchronises your computer's
  91. clock with @acronym{NTP, Network Time Protocol} servers, reference clocks such
  92. as GPS receivers, or even manual input of the correct time from a wristwatch.
  93. Chrony will determine the rate at which the computer gains or loses time, and
  94. compensate for it. It can also operate as an NTPv4 (RFC 5905) server and peer
  95. 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.
  100. Typical accuracy when synchronised over the Internet is several milliseconds.
  101. On a local network this can reach tens of microseconds. With hardware
  102. time-stamping or reference clock, sub-microsecond accuracy is possible.")
  103. (license l:gpl2)))
  104. (define-public ntp
  105. (package
  106. (name "ntp")
  107. (version "4.2.8p15")
  108. (source
  109. (origin
  110. (method url-fetch)
  111. (uri (list (string-append
  112. "https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-"
  113. (version-major+minor version)
  114. "/ntp-" version ".tar.gz")
  115. (string-append
  116. "http://archive.ntp.org/ntp4/ntp-"
  117. (version-major+minor version)
  118. "/ntp-" version ".tar.gz")))
  119. (sha256
  120. (base32 "06cwhimm71safmwvp6nhxp6hvxsg62whnbgbgiflsqb8mgg40n7n"))
  121. ;; Add an upstream patch to fix build with GCC 10. Taken from
  122. ;; <https://bugs.ntp.org/show_bug.cgi?id=3688>.
  123. (patches (list (origin
  124. (method url-fetch)
  125. (uri "https://bugs.ntp.org/attachment.cgi?id=1760\
  126. &action=diff&context=patch&collapsed=&headers=1&format=raw")
  127. (file-name "ntp-gcc-compat.patch")
  128. (sha256
  129. (base32
  130. "13d28sg45rflc7kqiv30asrhna8n69wlpwx16l65rravgpvp90h2")))))
  131. (modules '((guix build utils)))
  132. (snippet
  133. '(begin
  134. ;; Remove the bundled copy of libevent, but we must keep
  135. ;; sntp/libevent/build-aux since configure.ac contains
  136. ;; AC_CONFIG_AUX_DIR([sntp/libevent/build-aux])
  137. (rename-file "sntp/libevent/build-aux"
  138. "sntp/libevent:build-aux")
  139. (delete-file-recursively "sntp/libevent")
  140. (mkdir "sntp/libevent")
  141. (rename-file "sntp/libevent:build-aux"
  142. "sntp/libevent/build-aux")
  143. #t))))
  144. (native-inputs `(("which" ,which)
  145. ("pkg-config" ,pkg-config)))
  146. (inputs
  147. `(("openssl" ,openssl)
  148. ("libevent" ,libevent)
  149. ;; Build with POSIX capabilities support on GNU/Linux. This allows 'ntpd'
  150. ;; to run as non-root (when invoked with '-u'.)
  151. ,@(if (string-suffix? "-linux"
  152. (or (%current-target-system) (%current-system)))
  153. `(("libcap" ,libcap))
  154. '())))
  155. (arguments
  156. `(#:phases
  157. (modify-phases %standard-phases
  158. (add-after 'unpack 'disable-network-test
  159. (lambda _
  160. (substitute* "tests/libntp/Makefile.in"
  161. (("test-decodenetnum\\$\\(EXEEXT\\) ") ""))
  162. #t)))))
  163. (build-system gnu-build-system)
  164. (synopsis "Real time clock synchronization system")
  165. (description "NTP is a system designed to synchronize the clocks of
  166. computers over a network.")
  167. (license (l:x11-style
  168. "https://www.eecis.udel.edu/~mills/ntp/html/copyright.html"
  169. "A non-copyleft free licence from the University of Delaware"))
  170. (home-page "https://www.ntp.org")))
  171. (define-public openntpd
  172. (package
  173. (name "openntpd")
  174. (version "6.8p1")
  175. (source (origin
  176. (method url-fetch)
  177. (uri (string-append
  178. "mirror://openbsd/OpenNTPD/openntpd-" version ".tar.gz"))
  179. (sha256
  180. (base32
  181. "0ijsylc7a4jlpxsqa0jq1w1c7333id8pcakzl7a5749ria1xp0l5"))))
  182. (build-system gnu-build-system)
  183. (arguments
  184. `(#:configure-flags
  185. (let* ((libressl (assoc-ref %build-inputs "libressl"))
  186. (libressl-version ,(package-version
  187. (car (assoc-ref (package-inputs this-package)
  188. "libressl")))))
  189. (list "--with-privsep-user=ntpd"
  190. "--localstatedir=/var"
  191. (string-append "--with-cacert=" libressl
  192. "/share/libressl-" libressl-version
  193. "/cert.pem")))
  194. #:phases
  195. (modify-phases %standard-phases
  196. (add-after 'unpack 'modify-install-locations
  197. (lambda _
  198. ;; Don't try to create /var/run or /var/db
  199. (substitute* "src/Makefile.in"
  200. (("DESTDIR\\)\\$\\(localstatedir") "TMPDIR"))
  201. #t)))))
  202. (inputs
  203. `(("libressl" ,libressl))) ; enable TLS time constraints. See ntpd.conf(5).
  204. (home-page "http://www.openntpd.org/")
  205. (synopsis "NTP client and server by the OpenBSD Project")
  206. (description "OpenNTPD is the OpenBSD Project's implementation of a client
  207. and server for the Network Time Protocol. Its design goals include being
  208. secure, easy to configure, and accurate enough for most purposes, so it's more
  209. minimalist than ntpd.")
  210. ;; A few of the source files are under bsd-3.
  211. (license (list l:isc l:bsd-3))))