1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020, 2021 Hartmut Goebel <h.goebel@crazy-compilers.com>
3 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu packages sequoia)
21 #:use-module (guix build-system cargo)
22 #:use-module (guix build-system trivial)
23 #:use-module (guix download)
24 #:use-module (guix git-download)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix gexp)
28 #:use-module (guix utils)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages base) ; glibc
31 #:use-module (gnu packages check) ;; python-pytest
32 #:use-module (gnu packages crates-io)
33 #:use-module (gnu packages libffi) ;; python-cffi
34 #:use-module (gnu packages llvm)
35 #:use-module (gnu packages multiprecision)
36 #:use-module (gnu packages nettle)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages python-xyz) ;; python-setuptools
40 #:use-module (gnu packages rust)
41 #:use-module (gnu packages tls))
43 (define-public rust-sequoia-autocrypt-0.23
45 (name "rust-sequoia-autocrypt")
50 (uri (crate-uri "sequoia-autocrypt" version))
51 (file-name (string-append name "-" version ".tar.gz"))
53 (base32 "0skj0dv15341v470g6w5pggsl0iy27qb8h24rr8k6rq7vxdjxl7g"))))
54 (build-system cargo-build-system)
58 (("rust-base64" ,rust-base64-0.13)
59 ("rust-sequoia-openpgp" ,rust-sequoia-openpgp-1))
61 (modify-phases %standard-phases
62 (add-after 'unpack 'remove-other-crypto-features
64 (substitute* "Cargo.toml"
65 (("^crypto-cng =" line) (string-append "# " line))
66 (("^crypto-rust =" line) (string-append "# " line))))))))
67 (home-page "https://sequoia-pgp.org/")
68 (synopsis "Deal with Autocrypt encoded data")
69 (description "This crate implements low-level functionality like encoding
70 and decoding of Autocrypt headers and setup messages. Note: Autocrypt is more
71 than just headers; it requires tight integration with the MUA.")
72 (license license:lgpl2.0+)))
74 (define-public rust-sequoia-ipc-0.26
76 (name "rust-sequoia-ipc")
81 (uri (crate-uri "sequoia-ipc" version))
82 (file-name (string-append name "-" version ".tar.gz"))
84 (base32 "0xyhz55g1igzjw46f667kqmbbk7pgqy2zf5p13zspr6bwv39s1yk"))))
85 (build-system cargo-build-system)
89 (("rust-anyhow" ,rust-anyhow-1)
90 ("rust-buffered-reader" ,rust-buffered-reader-1)
91 ("rust-capnp-rpc" ,rust-capnp-rpc-0.13)
92 ("rust-ctor" ,rust-ctor-0.1)
93 ("rust-dirs" ,rust-dirs-2)
94 ("rust-fs2" ,rust-fs2-0.4)
95 ("rust-futures" ,rust-futures-0.3)
96 ("rust-lalrpop" ,rust-lalrpop-0.19)
97 ("rust-lalrpop-util" ,rust-lalrpop-util-0.19)
98 ("rust-lazy-static" ,rust-lazy-static-1)
99 ("rust-libc" ,rust-libc-0.2)
100 ("rust-memsec" ,rust-memsec-0.6)
101 ("rust-rand" ,rust-rand-0.7)
102 ("rust-sequoia-openpgp" ,rust-sequoia-openpgp-1)
103 ("rust-socket2" ,rust-socket2-0.3)
104 ("rust-tempfile" ,rust-tempfile-3)
105 ("rust-thiserror" ,rust-thiserror-1)
106 ("rust-tokio" ,rust-tokio-0.2)
107 ("rust-tokio-util" ,rust-tokio-util-0.3)
108 ("rust-winapi" ,rust-winapi-0.3))
109 #:cargo-development-inputs
110 (("rust-clap" ,rust-clap-2)
111 ("rust-quickcheck" ,rust-quickcheck-0.9))
113 (modify-phases %standard-phases
114 (add-after 'unpack 'remove-other-crypto-features
116 (substitute* "Cargo.toml"
117 (("^crypto-cng =" line) (string-append "# " line))
118 (("^crypto-rust =" line) (string-append "# " line))))))))
119 (home-page "https://sequoia-pgp.org/")
120 (synopsis "Interprocess communication infrastructure for Sequoia")
121 (description "Interprocess communication infrastructure for Sequoia")
122 (license license:lgpl2.0+)))
124 (define-public rust-sequoia-net-0.23
126 (name "rust-sequoia-net")
131 (uri (crate-uri "sequoia-net" version))
132 (file-name (string-append name "-" version ".tar.gz"))
134 (base32 "05gv053zqnb00mrai5hva3i4909hn77bnh4z1g4b29cw5qb52cbl"))))
135 (build-system cargo-build-system)
139 (("rust-anyhow" ,rust-anyhow-1)
140 ("rust-futures-util" ,rust-futures-util-0.3)
141 ("rust-http" ,rust-http-0.2)
142 ("rust-hyper" ,rust-hyper-0.13)
143 ("rust-hyper-tls" ,rust-hyper-tls-0.4)
144 ("rust-libc" ,rust-libc-0.2)
145 ("rust-native-tls" ,rust-native-tls-0.2)
146 ("rust-percent-encoding" ,rust-percent-encoding-2)
147 ("rust-sequoia-openpgp" ,rust-sequoia-openpgp-1)
148 ("rust-tempfile" ,rust-tempfile-3)
149 ("rust-thiserror" ,rust-thiserror-1)
150 ("rust-url" ,rust-url-2)
151 ("rust-zbase32" ,rust-zbase32-0.1))
153 (modify-phases %standard-phases
154 (add-after 'unpack 'remove-other-crypto-features
156 (substitute* "Cargo.toml"
157 (("^crypto-cng =" line) (string-append "# " line))
158 (("^crypto-rust =" line) (string-append "# " line))))))))
159 (home-page "https://sequoia-pgp.org/")
160 (synopsis "Discover and publish OpenPGP certificates over the network")
161 (description "This package provides a crate to access keyservers using the
162 HKP protocol, and searching and publishing Web Key Directories.")
163 (license license:lgpl2.0+)))
165 (define-public rust-sequoia-openpgp-1
167 (name "rust-sequoia-openpgp")
172 (uri (crate-uri "sequoia-openpgp" version))
173 (file-name (string-append name "-" version ".tar.gz"))
175 (base32 "1mdprsijszkg2j6jk1iq7q1z9yikq598y12m5zbv94fs37xlx3qm"))
176 (modules '((guix build utils)))
178 ;; Remove dependencies on rust-crypto and win32-cng
179 '(let* ((other-crypto-pkgs
181 "aes" "block-modes" "block-padding" "blowfish" "cast5"
182 "cipher" "des" "digest" "eax" "ed25519-dalek"
183 "generic-array" "idea" "md-5" "num-bigint-dig" "rand"
184 "ripemd160" "rsa" "sha-1" "sha2" "twofish" "typenum"
185 "x25519-dalek" "p256" "rand_core" "rand_core" "ecdsa"
187 "eax" "winapi" "win-crypto-ng" "ed25519-dalek"
189 (pkgs-pattern (pk (string-join
190 (list "^\\[dependencies\\.("
191 (string-join other-crypto-pkgs "|")
194 (substitute* "Cargo.toml"
195 ((pkgs-pattern line name) (string-append "[off." name "]"))
196 (("^crypto-cng =" line) (string-append "# " line))
197 (("^crypto-rust =" line) (string-append "# " line))
198 (("^\\[(target\\.\"cfg\\(windows\\))" line name)
199 (string-append "[off." name)))))))
200 (build-system cargo-build-system)
202 (list clang pkg-config))
208 (("rust-anyhow" ,rust-anyhow-1)
209 ("rust-backtrace" ,rust-backtrace-0.3)
210 ("rust-base64" ,rust-base64-0.13)
211 ("rust-buffered-reader" ,rust-buffered-reader-1)
212 ("rust-bzip2" ,rust-bzip2-0.4)
213 ("rust-chrono" ,rust-chrono-0.4)
214 ("rust-dyn-clone" ,rust-dyn-clone-1)
215 ("rust-flate2" ,rust-flate2-1)
216 ("rust-idna" ,rust-idna-0.2)
217 ("rust-itertools" ,rust-itertools-0.10)
218 ("rust-lalrpop" ,rust-lalrpop-0.19)
219 ("rust-lalrpop-util" ,rust-lalrpop-util-0.19)
220 ("rust-lazy-static" ,rust-lazy-static-1) ;; 1.4.0
221 ("rust-libc" ,rust-libc-0.2) ;; 0.2.66
222 ("rust-memsec" ,rust-memsec-0.6)
223 ("rust-nettle" ,rust-nettle-7)
224 ("rust-plotters" ,rust-plotters-0.3)
225 ("rust-regex" ,rust-regex-1)
226 ("rust-regex-syntax" ,rust-regex-syntax-0.6)
227 ("rust-sha1collisiondetection" ,rust-sha1collisiondetection-0.2)
228 ("rust-thiserror" ,rust-thiserror-1)
229 ("rust-unicode-normalization" ,rust-unicode-normalization-0.1)
230 ("rust-xxhash-rust" ,rust-xxhash-rust-0.8))
231 #:cargo-development-inputs
232 ;; keep the development-inputs to allow running tests easily
233 (("rust-criterion" ,rust-criterion-0.3)
234 ("rust-quickcheck" ,rust-quickcheck-0.9)
235 ("rust-rand" ,rust-rand-0.7)
236 ("rust-rpassword" ,rust-rpassword-5))))
237 (home-page "https://sequoia-pgp.org/")
238 (synopsis "OpenPGP data types and associated machinery")
239 (description "This crate aims to provide a complete implementation of
240 OpenPGP as defined by RFC 4880 as well as some extensions (e.g., RFC 6637,
241 which describes ECC cryptography) for OpenPGP. This includes support for
242 unbuffered message processing.
244 A few features that the OpenPGP community considers to be deprecated (e.g.,
245 version 3 compatibility) have been left out. The developers have also updated
246 some OpenPGP defaults to avoid foot guns (e.g., they selected modern algorithm
249 This Guix package is built to use the nettle cryptographic library.")
250 (license license:lgpl2.0+)))
252 (define-public rust-sequoia-openpgp-0.9
254 (inherit rust-sequoia-openpgp-1)
255 (name "rust-sequoia-openpgp")
260 (uri (crate-uri "sequoia-openpgp" version))
261 (file-name (string-append name "-" version ".tar.gz"))
263 (base32 "007h2pi7lcph5jf5bxjydm7hjwjai33yk6dic3cxknki22lxlkfw"))))
264 (build-system cargo-build-system)
268 (("rust-base64" ,rust-base64-0.9)
269 ("rust-buffered-reader" ,rust-buffered-reader-0.9)
270 ("rust-bzip2" ,rust-bzip2-0.3)
271 ("rust-failure" ,rust-failure-0.1)
272 ("rust-flate2" ,rust-flate2-1)
273 ("rust-idna" ,rust-idna-0.1)
274 ("rust-lalrpop" ,rust-lalrpop-0.17)
275 ("rust-lalrpop-util" ,rust-lalrpop-util-0.17)
276 ("rust-lazy-static" ,rust-lazy-static-1)
277 ("rust-memsec" ,rust-memsec-0.5)
278 ("rust-nettle" ,rust-nettle-5)
279 ("rust-quickcheck" ,rust-quickcheck-0.8)
280 ("rust-rand" ,rust-rand-0.6)
281 ("rust-sequoia-rfc2822" ,rust-sequoia-rfc2822-0.9)
282 ("rust-time" ,rust-time-0.1))))))
284 (define-public rust-sequoia-rfc2822-0.9
286 (name "rust-sequoia-rfc2822")
291 (uri (crate-uri "sequoia-rfc2822" version))
292 (file-name (string-append name "-" version ".tar.gz"))
294 (base32 "1aj34i6862718m162rqfv69fkmvdw063s6ws7hbp42n73gb08p5c"))))
295 (build-system cargo-build-system)
299 (("rust-failure" ,rust-failure-0.1)
300 ("rust-lalrpop" ,rust-lalrpop-0.17)
301 ("rust-lalrpop-util" ,rust-lalrpop-util-0.17))))
302 (home-page "https://sequoia-pgp.org/")
303 (synopsis "RFC 2822 name-addr parser")
304 (description "Currently, this crate only recognizes the RFC 2822 name-addr
305 and addr-spec productions, i.e., things of the form: @code{Name (Comment)
306 <email@@example.org>} and @code{email@@example.org}
308 Although the above appear simple to parse, RFC 2822's whitespace and comment
309 rules are rather complex. This crate implements the whole grammar." )
310 (license license:gpl3)))
312 (define-public sequoia-sq
319 (uri (crate-uri "sequoia-sq" version))
320 (file-name (string-append name "-" version ".tar.gz"))
322 (base32 "0j26vpp98i7zwwhqsvwj0zknj4s0s0ilfqpynj1vgd5laanhyr0d"))))
323 (build-system cargo-build-system)
325 (list nettle openssl))
327 (list clang pkg-config))
329 `(#:tests? #f ;; tests require data-files not provided in the package
332 (("rust-anyhow" ,rust-anyhow-1)
333 ("rust-buffered-reader" ,rust-buffered-reader-1)
334 ("rust-chrono" ,rust-chrono-0.4)
335 ("rust-clap" ,rust-clap-2)
336 ("rust-clap" ,rust-clap-2)
337 ("rust-itertools" ,rust-itertools-0.9)
338 ("rust-rpassword" ,rust-rpassword-5)
339 ("rust-sequoia-autocrypt" ,rust-sequoia-autocrypt-0.23)
340 ("rust-sequoia-net" ,rust-sequoia-net-0.23)
341 ("rust-sequoia-openpgp" ,rust-sequoia-openpgp-1)
342 ("rust-tempfile" ,rust-tempfile-3)
343 ("rust-term-size" ,rust-term-size-0.3)
344 ("rust-tokio" ,rust-tokio-0.2))
345 #:cargo-development-inputs
346 (("rust-assert-cli" ,rust-assert-cli-0.6))
348 (modify-phases %standard-phases
349 (add-after 'unpack 'remove-other-crypto-features
351 (substitute* "Cargo.toml"
352 (("^crypto-cng =" line) (string-append "# " line))
353 (("^crypto-rust =" line) (string-append "# " line))))))))
354 (home-page "https://sequoia-pgp.org/")
355 (synopsis "Command-line frontend for Sequoia OpenPGP")
356 (description "This package provides the command-line frontend for Sequoia
359 This Guix package is built to use the nettle cryptographic library.")
360 (license license:lgpl2.0+)))
362 (define-public sequoia-sqv
369 (uri (crate-uri "sequoia-sqv" version))
370 (file-name (string-append name "-" version ".tar.gz"))
372 (base32 "0nrfjn64fm038x5dssipf7jxi27z741m5n5a7zsa9768zab1hr9d"))))
373 (build-system cargo-build-system)
375 (list nettle openssl))
377 (list clang pkg-config))
379 `(#:tests? #f ;; tests require data-files not provided in the package
382 (("rust-anyhow" ,rust-anyhow-1)
383 ("rust-chrono" ,rust-chrono-0.4)
384 ("rust-clap" ,rust-clap-2)
385 ("rust-clap" ,rust-clap-2)
386 ("rust-sequoia-openpgp" ,rust-sequoia-openpgp-1))
387 #:cargo-development-inputs
388 (("rust-assert-cli" ,rust-assert-cli-0.6))
390 (modify-phases %standard-phases
391 (add-after 'unpack 'remove-other-crypto-features
393 (substitute* "Cargo.toml"
394 (("^crypto-cng =" line) (string-append "# " line))
395 (("^crypto-rust =" line) (string-append "# " line))))))))
396 (home-page "https://sequoia-pgp.org/")
397 (synopsis "Simple OpenPGP signature verification program")
398 (description "@code{sqv} verifies detached OpenPGP signatures. It is a
399 replacement for @code{gpgv}. Unlike @code{gpgv}, it can take additional
400 constraints on the signature into account.
402 This Guix package is built to use the nettle cryptographic library.")
403 (license license:lgpl2.0+)))
405 (define (sequoia-package-origin version)
409 (url "https://gitlab.com/sequoia-pgp/sequoia.git")
410 (commit (string-append "openpgp/v" version))))
412 (base32 "1cq1xgvllbpii5hfl3wlia2ayznpvhv8lq8g8ygwxga86ijg98lq"))
413 (file-name (git-file-name "sequoia" version))
414 (patches (search-patches "libsequoia-remove-store.patch"
415 "libsequoia-fix-ffi-Makefile.patch"))))
417 (define-public libsequoia
421 (source (sequoia-package-origin "1.6.0"))
422 (build-system cargo-build-system)
423 (outputs '("out" "python"))
425 (list clang pkg-config python-pytest python-pytest-runner
428 (list gmp nettle openssl python python-cffi))
431 #:tests? #f ;; TODO make python tests find the shared object file
433 `(("rust-anyhow" ,rust-anyhow-1)
434 ("rust-lazy-static" ,rust-lazy-static-1)
435 ("rust-libc" ,rust-libc-0.2)
436 ("rust-memsec" ,rust-memsec-0.6)
437 ("rust-native-tls" ,rust-native-tls-0.2)
438 ("rust-proc-macro2" ,rust-proc-macro2-1) ;; for ffi-macros
439 ("rust-quote" ,rust-quote-1) ;; for ffi-macros
440 ("rust-sequoia-ipc" ,rust-sequoia-ipc-0.26)
441 ("rust-sequoia-net" ,rust-sequoia-net-0.23)
442 ("rust-sequoia-openpgp" ,rust-sequoia-openpgp-1)
443 ("rust-sha2" ,rust-sha2-0.8) ;; for ffi-macros
444 ("rust-tokio" ,rust-tokio-1.8))
445 #:cargo-development-inputs
446 `(("rust-filetime" ,rust-filetime-0.2))
448 #~(modify-phases %standard-phases
449 (add-after 'configure 'set-PREFIX
451 (setenv "PREFIX" #$output)))
454 (invoke "make" "-C" "openpgp-ffi" "build-release")
455 (invoke "make" "-C" "ffi" "build-release")))
456 (delete 'package) ;; cargo can't package a multi-crate workspace
458 (lambda* (#:key tests? #:allow-other-keys)
461 (invoke "make" "-C" "openpgp-ffi" "check")
462 (invoke "make" "-C" "ffi" "check")))))
465 (invoke "make" "-C" "openpgp-ffi" "install")
466 (invoke "make" "-C" "ffi" "install")))
467 (add-after 'configure 'fix-build-environment
469 (delete-file "Cargo.toml")
470 (symlink "../.cargo" "openpgp-ffi/.cargo")
471 (symlink "../.cargo" "ffi/.cargo")
472 (for-each delete-file-recursively
473 (find-files "guix-vendor" "^sequoia-[0-9]+\\.*"
474 #:directories? #t))))
475 (add-after 'unpack 'fix-for-python-output
477 (substitute* "ffi/lang/python/Makefile"
478 ;; adjust prefix for python package
479 (("PREFIX\\s*\\??=.*")
480 (string-append "PREFIX = " (pk #$output:python) "\n"))
481 ;; fix rpath to include the main package
482 (("\\WLDFLAGS=" text)
483 (string-append text "'-Wl,-rpath=" #$output "/lib '"))
484 ;; make setuptools install into the prefix, see
485 ;; guix/build/python-build-system.scm for explanation
486 (("\\ssetup.py\\s+install\\s")
487 " setup.py install --root=/ --single-version-externally-managed "))))
488 (add-after 'unpack 'fix-Makefiles
490 (substitute* '("openpgp-ffi/Makefile")
491 (("^check-headers: force-build") "check-headers:"))))
492 (add-after 'unpack 'remove-other-crypto-features
494 (substitute* '("openpgp-ffi/Cargo.toml" "ffi/Cargo.toml")
495 (("^crypto-cng =" line) (string-append "# " line))
496 (("^crypto-rust =" line) (string-append "# " line)))))
497 (add-after 'unpack 'fix-missing-feature
499 (substitute* '("ffi/Cargo.toml")
500 (("^(tokio = .* features = \\[)" line)
501 (string-append line "\"net\", ")))))
502 (add-after 'unpack 'unbundle-crates
504 (substitute* '("openpgp-ffi/Cargo.toml" "ffi/Cargo.toml")
505 (("path = \"\\.\\./(openpgp|store|net|ipc)\",") "")))))))
506 (home-page "https://sequoia-pgp.org")
507 (synopsis "C/FFI interfaces for Sequoia-PGP")
508 (description "This package provides a C and FFI interface to both the
509 low-level and a high-level API of Sequoia-PGP.
511 Use with caution: This is an \"unofficial\" package, which are not officially
512 released, but part of the Sequoia-PGP v1.6.0 archive. So this package might
514 (license license:lgpl2.0+)))
516 (define-public sequoia
521 (build-system trivial-build-system)
522 (outputs '("out" "python"))
524 (list glibc ;; for ldconfig in make-dynamic-linker-cache
526 `(,libsequoia "python")
531 #:modules '((guix build utils) (guix build gnu-build-system)
532 (guix build gremlin) (guix elf))
535 (use-modules (guix build utils) (guix build gnu-build-system))
536 (let ((make-dynamic-linker-cache
537 (assoc-ref %standard-phases 'make-dynamic-linker-cache))
539 (string-append #$output "/etc/ld.so.cache")))
540 (copy-recursively #$libsequoia #$output)
541 (copy-recursively #$sequoia-sq #$output)
542 (delete-file ld.so.cache)
543 (copy-recursively #$sequoia-sqv #$output)
544 (delete-file ld.so.cache)
545 (copy-recursively #$libsequoia:python #$output:python)
547 (string-append (getenv "PATH") ":" #$glibc "/sbin"))
548 (make-dynamic-linker-cache #:outputs %outputs)))))
549 (home-page "https://sequoia-pgp.org")
550 (synopsis "New OpenPGP implementation (meta-package)")
551 (description "Sequoia is a new OpenPGP implementation, written in Rust,
552 consisting of several Rust crates/packages. This Guix meta-package combines
553 these packages into a single one for convenience. Anyhow, you should not
554 depend other packages on this one avoid excessive compile-times for users.")
555 (license license:lgpl2.0+)))