gnu: ruby-pandoc-ruby: Use pandoc instead of ghc-pandoc.
[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 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 Marius Bakke <mbakke@fastmail.com>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages nss)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix build-system gnu)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages check)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages perl)
32 #:use-module (gnu packages sqlite)
33 #:use-module (ice-9 match))
34
35 (define-public nspr
36 (package
37 (name "nspr")
38 (version "4.25")
39 (source (origin
40 (method url-fetch)
41 (uri (string-append
42 "https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v"
43 version "/src/nspr-" version ".tar.gz"))
44 (sha256
45 (base32
46 "0mjjk2b7ika3v4y99cnaqz3z1iq1a50r1psn9i3s87gr46z0khqb"))))
47 (build-system gnu-build-system)
48 (native-inputs
49 `(("perl" ,perl)))
50 (arguments
51 `(#:tests? #f ; no check target
52 #:configure-flags (list "--disable-static"
53 "--enable-64bit"
54 (string-append "LDFLAGS=-Wl,-rpath="
55 (assoc-ref %outputs "out")
56 "/lib"))
57 ;; Use fixed timestamps for reproducibility.
58 #:make-flags '("SH_DATE='1970-01-01 00:00:01'"
59 ;; This is epoch 1 in microseconds.
60 "SH_NOW=100000")
61 #:phases (modify-phases %standard-phases
62 (add-before 'configure 'chdir
63 (lambda _ (chdir "nspr") #t)))))
64 (home-page
65 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR")
66 (synopsis "Netscape API for system level and libc-like functions")
67 (description "Netscape Portable Runtime (@dfn{NSPR}) provides a
68 platform-neutral API for system level and libc-like functions. It is used
69 in the Mozilla clients.")
70 (license license:mpl2.0)))
71
72 (define-public nss
73 (package
74 (name "nss")
75 (version "3.52.1")
76 (source (origin
77 (method url-fetch)
78 (uri (let ((version-with-underscores
79 (string-join (string-split version #\.) "_")))
80 (string-append
81 "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
82 "releases/NSS_" version-with-underscores "_RTM/src/"
83 "nss-" version ".tar.gz")))
84 (sha256
85 (base32
86 "0y4jb9095f7bbgw7d7kvzm4c3g4p5i6y68fwhb8wlkpb7b1imj5w"))
87 ;; Create nss.pc and nss-config.
88 (patches (search-patches "nss-pkgconfig.patch"
89 "nss-increase-test-timeout.patch"))
90 (modules '((guix build utils)))
91 (snippet
92 '(begin
93 ;; Delete the bundled copy of these libraries.
94 (delete-file-recursively "nss/lib/zlib")
95 (delete-file-recursively "nss/lib/sqlite")
96 #t))))
97 (build-system gnu-build-system)
98 (outputs '("out" "bin"))
99 (arguments
100 `(#:parallel-build? #f ; not supported
101 #:make-flags
102 (let* ((out (assoc-ref %outputs "out"))
103 (nspr (string-append (assoc-ref %build-inputs "nspr")))
104 (rpath (string-append "-Wl,-rpath=" out "/lib/nss")))
105 (list "-C" "nss" (string-append "PREFIX=" out)
106 "NSDISTMODE=copy"
107 "NSS_USE_SYSTEM_SQLITE=1"
108 (string-append "NSPR_INCLUDE_DIR=" nspr "/include/nspr")
109 ;; Add $out/lib/nss to RPATH.
110 (string-append "RPATH=" rpath)
111 (string-append "LDFLAGS=" rpath)))
112 #:modules ((guix build gnu-build-system)
113 (guix build utils)
114 (ice-9 ftw)
115 (ice-9 match)
116 (srfi srfi-26))
117 #:phases
118 (modify-phases %standard-phases
119 (replace 'configure
120 (lambda _
121 (setenv "CC" "gcc")
122 ;; Tells NSS to build for the 64-bit ABI if we are 64-bit system.
123 ,@(match (%current-system)
124 ((or "x86_64-linux" "aarch64-linux")
125 `((setenv "USE_64" "1")))
126 (_
127 '()))
128 #t))
129 (replace 'check
130 (lambda _
131 ;; Use 127.0.0.1 instead of $HOST.$DOMSUF as HOSTADDR for testing.
132 ;; The later requires a working DNS or /etc/hosts.
133 (setenv "DOMSUF" "localdomain")
134 (setenv "USE_IP" "TRUE")
135 (setenv "IP_ADDRESS" "127.0.0.1")
136
137 ;; The "PayPalEE.cert" certificate expires every six months,
138 ;; leading to test failures:
139 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=609734>. To
140 ;; work around that, set the time to roughly the release date.
141 (invoke "faketime" "2020-02-01" "./nss/tests/all.sh")))
142 (replace 'install
143 (lambda* (#:key outputs #:allow-other-keys)
144 (let* ((out (assoc-ref outputs "out"))
145 (bin (string-append (assoc-ref outputs "bin") "/bin"))
146 (inc (string-append out "/include/nss"))
147 (lib (string-append out "/lib/nss"))
148 (obj (match (scandir "dist" (cut string-suffix? "OBJ" <>))
149 ((obj) (string-append "dist/" obj)))))
150 ;; Install nss-config to $out/bin.
151 (install-file (string-append obj "/bin/nss-config")
152 (string-append out "/bin"))
153 (delete-file (string-append obj "/bin/nss-config"))
154 ;; Install nss.pc to $out/lib/pkgconfig.
155 (install-file (string-append obj "/lib/pkgconfig/nss.pc")
156 (string-append out "/lib/pkgconfig"))
157 (delete-file (string-append obj "/lib/pkgconfig/nss.pc"))
158 (rmdir (string-append obj "/lib/pkgconfig"))
159 ;; Install other files.
160 (copy-recursively "dist/public/nss" inc)
161 (copy-recursively (string-append obj "/bin") bin)
162 (copy-recursively (string-append obj "/lib") lib)
163
164 ;; FIXME: libgtest1.so is installed in the above step, and it's
165 ;; (unnecessarily) linked with several NSS libraries, but
166 ;; without the needed rpaths, causing the 'validate-runpath'
167 ;; phase to fail. Here we simply delete libgtest1.so, since it
168 ;; seems to be used only during the tests.
169 (delete-file (string-append lib "/libgtest1.so"))
170 (delete-file (string-append lib "/libgtestutil.so"))
171
172 #t))))))
173 (inputs
174 `(("sqlite" ,sqlite)
175 ("zlib" ,zlib)))
176 (propagated-inputs `(("nspr" ,nspr))) ; required by nss.pc.
177 (native-inputs `(("perl" ,perl)
178 ("libfaketime" ,libfaketime))) ;for tests
179
180 ;; The NSS test suite takes around 48 hours on Loongson 3A (MIPS) when
181 ;; another build is happening concurrently on the same machine.
182 (properties '((timeout . 216000))) ; 60 hours
183
184 (home-page
185 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS")
186 (synopsis "Network Security Services")
187 (description
188 "Network Security Services (@dfn{NSS}) is a set of libraries designed to
189 support cross-platform development of security-enabled client and server
190 applications. Applications built with NSS can support SSL v2 and v3, TLS,
191 PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other
192 security standards.")
193 (license license:mpl2.0)))