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