gnu: ffmpeg@4: Build against SDL2 2.0 so 'ffplay' gets built.
[jackhill/guix/guix.git] / gnu / packages / nss.scm
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, 2021 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016-2019, 2021, 2022 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
26 (define-module (gnu packages nss)
27 #:use-module (guix packages)
28 #:use-module (guix utils)
29 #:use-module (guix gexp)
30 #:use-module (guix download)
31 #:use-module (guix build-system gnu)
32 #:use-module ((guix licenses) #:prefix license:)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages bash)
35 #:use-module (gnu packages check)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages perl)
38 #:use-module (gnu packages sqlite))
39
40 (define-public nspr
41 (package
42 (name "nspr")
43 (version "4.31")
44 (source (origin
45 (method url-fetch)
46 (uri (string-append
47 "https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v"
48 version "/src/nspr-" version ".tar.gz"))
49 (sha256
50 (base32
51 "1j5b2m8cjlhnnv8sq34587avaagkqvh521w4f95miwgvsn3xlaap"))))
52 (build-system gnu-build-system)
53 (inputs
54 ;; For 'compile-et.pl' and 'nspr-config'.
55 (list perl ;for 'compile-et.pl'
56 bash-minimal)) ;for 'nspr-config'
57 (native-inputs
58 (list perl))
59 (arguments
60 `(;; Prevent the 'native' perl from sneaking into the closure.
61 ;; XXX it would be nice to do the same for 'bash-minimal',
62 ;; but using 'canonical-package' causes loops.
63 ,@(if (%current-target-system)
64 `(#:disallowed-references
65 (,(gexp-input (this-package-native-input "perl") #:native? #t)))
66 '())
67 #:tests? #f ; no check target
68 #:configure-flags
69 (list "--disable-static"
70 "--enable-64bit"
71 (string-append "LDFLAGS=-Wl,-rpath="
72 (assoc-ref %outputs "out") "/lib")
73 ;; Mozilla deviates from Autotools conventions
74 ;; due to historical reasons. Adjust to Mozilla conventions,
75 ;; otherwise the Makefile will try to use TARGET-gcc
76 ;; as a ‘native’ compiler.
77 ,@(if (%current-target-system)
78 `(,(string-append "--host="
79 (nix-system->gnu-triplet (%current-system)))
80 ,(string-append "--target=" (%current-target-system)))
81 '()))
82 ;; Use fixed timestamps for reproducibility.
83 #:make-flags '("SH_DATE='1970-01-01 00:00:01'"
84 ;; This is epoch 1 in microseconds.
85 "SH_NOW=100000")
86 #:phases (modify-phases %standard-phases
87 (add-before 'configure 'chdir
88 (lambda _ (chdir "nspr") #t)))))
89 (home-page
90 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR")
91 (synopsis "Netscape API for system level and libc-like functions")
92 (description "Netscape Portable Runtime (@dfn{NSPR}) provides a
93 platform-neutral API for system level and libc-like functions. It is used
94 in the Mozilla clients.")
95 (license license:mpl2.0)))
96
97 (define-public nspr-4.32
98 (package
99 (inherit nspr)
100 (version "4.32")
101 (source (origin
102 (method url-fetch)
103 (uri (string-append
104 "https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v"
105 version "/src/nspr-" version ".tar.gz"))
106 (sha256
107 (base32
108 "0v3zds1id71j5a5si42a658fjz8nv2f6zp6w4gqrqmdr6ksz8sxv"))))))
109
110 (define-public nss
111 (package
112 (name "nss")
113 ;; Also update and test the nss-certs package, which duplicates version and
114 ;; source to avoid a top-level variable reference & module cycle.
115 (version "3.72")
116 (source (origin
117 (method url-fetch)
118 (uri (let ((version-with-underscores
119 (string-join (string-split version #\.) "_")))
120 (string-append
121 "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
122 "releases/NSS_" version-with-underscores "_RTM/src/"
123 "nss-" version ".tar.gz")))
124 (sha256
125 (base32
126 "0bnh683nij6s0gvjcgwhyw5d3yx9fpm42pxj5bm97r0ky6ghm9kf"))
127 ;; Create nss.pc and nss-config.
128 (patches (search-patches "nss-3.56-pkgconfig.patch"
129 "nss-getcwd-nonnull.patch"
130 "nss-increase-test-timeout.patch"))
131 (modules '((guix build utils)))
132 (snippet
133 '(begin
134 ;; Delete the bundled copy of these libraries.
135 (delete-file-recursively "nss/lib/zlib")
136 (delete-file-recursively "nss/lib/sqlite")))))
137 (build-system gnu-build-system)
138 (outputs '("out" "bin"))
139 (arguments
140 `(#:make-flags
141 (let* ((out (assoc-ref %outputs "out"))
142 (nspr (string-append (assoc-ref %build-inputs "nspr")))
143 (rpath (string-append "-Wl,-rpath=" out "/lib/nss")))
144 (list "-C" "nss" (string-append "PREFIX=" out)
145 "NSDISTMODE=copy"
146 "NSS_USE_SYSTEM_SQLITE=1"
147 ;; The gtests fail to compile on riscv64.
148 ;; Skipping them doesn't affect the test suite.
149 ,@(if (target-riscv64?)
150 `("NSS_DISABLE_GTESTS=1")
151 '())
152 (string-append "NSPR_INCLUDE_DIR=" nspr "/include/nspr")
153 ;; Add $out/lib/nss to RPATH.
154 (string-append "RPATH=" rpath)
155 (string-append "LDFLAGS=" rpath)))
156 #:modules ((guix build gnu-build-system)
157 (guix build utils)
158 (ice-9 ftw)
159 (ice-9 match)
160 (srfi srfi-26))
161 #:tests? ,(not (or (%current-target-system)
162 ;; Tests take more than 30 hours on riscv64-linux.
163 (target-riscv64?)))
164 #:phases
165 (modify-phases %standard-phases
166 (replace 'configure
167 (lambda _
168 (setenv "CC" ,(cc-for-target))
169 ;; Tells NSS to build for the 64-bit ABI if we are 64-bit system.
170 ,@(if (target-64bit?)
171 `((setenv "USE_64" "1"))
172 '())))
173 (replace 'check
174 (lambda* (#:key tests? #:allow-other-keys)
175 (if tests?
176 (begin
177 ;; Use 127.0.0.1 instead of $HOST.$DOMSUF as HOSTADDR for
178 ;; testing. The latter requires a working DNS or /etc/hosts.
179 (setenv "DOMSUF" "localdomain")
180 (setenv "USE_IP" "TRUE")
181 (setenv "IP_ADDRESS" "127.0.0.1")
182
183 ;; The "PayPalEE.cert" certificate expires every six months,
184 ;; leading to test failures:
185 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=609734>. To
186 ;; work around that, set the time to roughly the release date.
187 (invoke "faketime" "2021-09-30" "./nss/tests/all.sh"))
188 (format #t "test suite not run~%"))))
189 (replace 'install
190 (lambda* (#:key outputs #:allow-other-keys)
191 (let* ((out (assoc-ref outputs "out"))
192 (bin (string-append (assoc-ref outputs "bin") "/bin"))
193 (inc (string-append out "/include/nss"))
194 (lib (string-append out "/lib/nss"))
195 (obj (match (scandir "dist" (cut string-suffix? "OBJ" <>))
196 ((obj) (string-append "dist/" obj)))))
197 ;; Install nss-config to $out/bin.
198 (install-file (string-append obj "/bin/nss-config")
199 (string-append out "/bin"))
200 (delete-file (string-append obj "/bin/nss-config"))
201 ;; Install nss.pc to $out/lib/pkgconfig.
202 (install-file (string-append obj "/lib/pkgconfig/nss.pc")
203 (string-append out "/lib/pkgconfig"))
204 (delete-file (string-append obj "/lib/pkgconfig/nss.pc"))
205 (rmdir (string-append obj "/lib/pkgconfig"))
206 ;; Install other files.
207 (copy-recursively "dist/public/nss" inc)
208 (copy-recursively (string-append obj "/bin") bin)
209 (copy-recursively (string-append obj "/lib") lib)))))))
210 (inputs
211 (list sqlite zlib))
212 (propagated-inputs
213 (list nspr)) ;required by nss.pc.
214 (native-inputs
215 (list perl libfaketime)) ;for tests
216
217 ;; The NSS test suite takes around 48 hours on Loongson 3A (MIPS) when
218 ;; another build is happening concurrently on the same machine.
219 (properties '((timeout . 216000))) ;60 hours
220
221 (home-page "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS")
222 (synopsis "Network Security Services")
223 (description
224 "Network Security Services (@dfn{NSS}) is a set of libraries designed to
225 support cross-platform development of security-enabled client and server
226 applications. Applications built with NSS can support SSL v2 and v3, TLS,
227 PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other
228 security standards.")
229 (license license:mpl2.0)))