nss.scm 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Mark H Weaver <mhw@netris.org>
  4. ;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
  5. ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  6. ;;; Copyright © 2020, 2021 Marius Bakke <marius@gnu.org>
  7. ;;; Copyright © 2020 Jonathan Brielmaier <jonathan.brielmaier@web.de>
  8. ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  9. ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
  10. ;;;
  11. ;;; This file is part of GNU Guix.
  12. ;;;
  13. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  14. ;;; under the terms of the GNU General Public License as published by
  15. ;;; the Free Software Foundation; either version 3 of the License, or (at
  16. ;;; your option) any later version.
  17. ;;;
  18. ;;; GNU Guix is distributed in the hope that it will be useful, but
  19. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;;; GNU General Public License for more details.
  22. ;;;
  23. ;;; You should have received a copy of the GNU General Public License
  24. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  25. (define-module (gnu packages nss)
  26. #:use-module (guix packages)
  27. #:use-module (guix utils)
  28. #:use-module (guix gexp)
  29. #:use-module (guix download)
  30. #:use-module (guix build-system gnu)
  31. #:use-module ((guix licenses) #:prefix license:)
  32. #:use-module (gnu packages)
  33. #:use-module (gnu packages bash)
  34. #:use-module (gnu packages check)
  35. #:use-module (gnu packages compression)
  36. #:use-module (gnu packages perl)
  37. #:use-module (gnu packages sqlite))
  38. (define-public nspr
  39. (package
  40. (name "nspr")
  41. (version "4.31")
  42. (source (origin
  43. (method url-fetch)
  44. (uri (string-append
  45. "https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v"
  46. version "/src/nspr-" version ".tar.gz"))
  47. (sha256
  48. (base32
  49. "1j5b2m8cjlhnnv8sq34587avaagkqvh521w4f95miwgvsn3xlaap"))))
  50. (build-system gnu-build-system)
  51. (inputs
  52. ;; TODO(core-updates): Make these inputs unconditional.
  53. ;; For 'compile-et.pl' and 'nspr-config'.
  54. (if (%current-target-system)
  55. `(("perl" ,perl) ; for 'compile-et.pl'
  56. ("bash-minimal" ,bash-minimal)) ; for 'nspr-config'
  57. '()))
  58. (native-inputs
  59. `(("perl" ,perl)))
  60. (arguments
  61. `(;; Prevent the 'native' perl from sneaking into the closure.
  62. ;; XXX it would be nice to do the same for 'bash-minimal',
  63. ;; but using 'canonical-package' causes loops.
  64. ,@(if (%current-target-system)
  65. `(#:disallowed-references
  66. (,(gexp-input (this-package-native-input "perl") #:native? #t)))
  67. '())
  68. #:tests? #f ; no check target
  69. #:configure-flags
  70. (list "--disable-static"
  71. "--enable-64bit"
  72. (string-append "LDFLAGS=-Wl,-rpath="
  73. (assoc-ref %outputs "out") "/lib")
  74. ;; Mozilla deviates from Autotools conventions
  75. ;; due to historical reasons. Adjust to Mozilla conventions,
  76. ;; otherwise the Makefile will try to use TARGET-gcc
  77. ;; as a ‘native’ compiler.
  78. ,@(if (%current-target-system)
  79. `(,(string-append "--host="
  80. (nix-system->gnu-triplet (%current-system)))
  81. ,(string-append "--target=" (%current-target-system)))
  82. '()))
  83. ;; Use fixed timestamps for reproducibility.
  84. #:make-flags '("SH_DATE='1970-01-01 00:00:01'"
  85. ;; This is epoch 1 in microseconds.
  86. "SH_NOW=100000")
  87. #:phases (modify-phases %standard-phases
  88. (add-before 'configure 'chdir
  89. (lambda _ (chdir "nspr") #t)))))
  90. (home-page
  91. "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR")
  92. (synopsis "Netscape API for system level and libc-like functions")
  93. (description "Netscape Portable Runtime (@dfn{NSPR}) provides a
  94. platform-neutral API for system level and libc-like functions. It is used
  95. in the Mozilla clients.")
  96. (license license:mpl2.0)))
  97. ;;; Note: When updating, also update the nss-certs package, which cannot
  98. ;;; inherit from here.
  99. (define-public nss
  100. (package
  101. (name "nss")
  102. (version "3.67")
  103. (source (origin
  104. (method url-fetch)
  105. (uri (let ((version-with-underscores
  106. (string-join (string-split version #\.) "_")))
  107. (string-append
  108. "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
  109. "releases/NSS_" version-with-underscores "_RTM/src/"
  110. "nss-" version ".tar.gz")))
  111. (sha256
  112. (base32
  113. "0zyfi27lbdz1bmk9dmsivcya4phx25rzlxqcnjab69yd928rlm7n"))
  114. ;; Create nss.pc and nss-config.
  115. (patches (search-patches "nss-3.56-pkgconfig.patch"
  116. "nss-getcwd-nonnull.patch"
  117. "nss-increase-test-timeout.patch"))
  118. (modules '((guix build utils)))
  119. (snippet
  120. '(begin
  121. ;; Delete the bundled copy of these libraries.
  122. (delete-file-recursively "nss/lib/zlib")
  123. (delete-file-recursively "nss/lib/sqlite")))))
  124. (build-system gnu-build-system)
  125. (outputs '("out" "bin"))
  126. (arguments
  127. `(#:make-flags
  128. (let* ((out (assoc-ref %outputs "out"))
  129. (nspr (string-append (assoc-ref %build-inputs "nspr")))
  130. (rpath (string-append "-Wl,-rpath=" out "/lib/nss")))
  131. (list "-C" "nss" (string-append "PREFIX=" out)
  132. "NSDISTMODE=copy"
  133. "NSS_USE_SYSTEM_SQLITE=1"
  134. (string-append "NSPR_INCLUDE_DIR=" nspr "/include/nspr")
  135. ;; Add $out/lib/nss to RPATH.
  136. (string-append "RPATH=" rpath)
  137. (string-append "LDFLAGS=" rpath)))
  138. #:modules ((guix build gnu-build-system)
  139. (guix build utils)
  140. (ice-9 ftw)
  141. (ice-9 match)
  142. (srfi srfi-26))
  143. #:phases
  144. (modify-phases %standard-phases
  145. (replace 'configure
  146. (lambda _
  147. (setenv "CC" ,(cc-for-target))
  148. ;; Tells NSS to build for the 64-bit ABI if we are 64-bit system.
  149. ,@(if (target-64bit?)
  150. `((setenv "USE_64" "1"))
  151. '())))
  152. (replace 'check
  153. (lambda* (#:key tests? #:allow-other-keys)
  154. (if tests?
  155. (begin
  156. ;; Use 127.0.0.1 instead of $HOST.$DOMSUF as HOSTADDR for
  157. ;; testing. The latter requires a working DNS or /etc/hosts.
  158. (setenv "DOMSUF" "localdomain")
  159. (setenv "USE_IP" "TRUE")
  160. (setenv "IP_ADDRESS" "127.0.0.1")
  161. ;; The "PayPalEE.cert" certificate expires every six months,
  162. ;; leading to test failures:
  163. ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=609734>. To
  164. ;; work around that, set the time to roughly the release date.
  165. (invoke "faketime" "2021-06-01" "./nss/tests/all.sh"))
  166. (format #t "test suite not run~%"))))
  167. (replace 'install
  168. (lambda* (#:key outputs #:allow-other-keys)
  169. (let* ((out (assoc-ref outputs "out"))
  170. (bin (string-append (assoc-ref outputs "bin") "/bin"))
  171. (inc (string-append out "/include/nss"))
  172. (lib (string-append out "/lib/nss"))
  173. (obj (match (scandir "dist" (cut string-suffix? "OBJ" <>))
  174. ((obj) (string-append "dist/" obj)))))
  175. ;; Install nss-config to $out/bin.
  176. (install-file (string-append obj "/bin/nss-config")
  177. (string-append out "/bin"))
  178. (delete-file (string-append obj "/bin/nss-config"))
  179. ;; Install nss.pc to $out/lib/pkgconfig.
  180. (install-file (string-append obj "/lib/pkgconfig/nss.pc")
  181. (string-append out "/lib/pkgconfig"))
  182. (delete-file (string-append obj "/lib/pkgconfig/nss.pc"))
  183. (rmdir (string-append obj "/lib/pkgconfig"))
  184. ;; Install other files.
  185. (copy-recursively "dist/public/nss" inc)
  186. (copy-recursively (string-append obj "/bin") bin)
  187. (copy-recursively (string-append obj "/lib") lib)))))))
  188. (inputs
  189. `(;; XXX: Build with SQLite 3.33 to work around
  190. ;; https://bugzilla.mozilla.org/show_bug.cgi?id=1714874
  191. ("sqlite" ,sqlite-3.33)
  192. ("zlib" ,zlib)))
  193. (propagated-inputs
  194. `(("nspr" ,nspr))) ;required by nss.pc.
  195. (native-inputs
  196. `(("perl" ,perl)
  197. ("libfaketime" ,libfaketime))) ;for tests
  198. ;; The NSS test suite takes around 48 hours on Loongson 3A (MIPS) when
  199. ;; another build is happening concurrently on the same machine.
  200. (properties '((timeout . 216000))) ;60 hours
  201. (home-page "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS")
  202. (synopsis "Network Security Services")
  203. (description
  204. "Network Security Services (@dfn{NSS}) is a set of libraries designed to
  205. support cross-platform development of security-enabled client and server
  206. applications. Applications built with NSS can support SSL v2 and v3, TLS,
  207. PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other
  208. security standards.")
  209. (license license:mpl2.0)))