sequoia.scm 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  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.
  11. ;;;
  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.
  16. ;;;
  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/>.
  19. (define-module (gnu packages sequoia)
  20. #:use-module (guix build-system cargo)
  21. #:use-module (guix download)
  22. #:use-module (guix git-download)
  23. #:use-module ((guix licenses) #:prefix license:)
  24. #:use-module (guix packages)
  25. #:use-module (guix utils)
  26. #:use-module (gnu packages)
  27. #:use-module (gnu packages check) ;; python-pytest
  28. #:use-module (gnu packages crates-io)
  29. #:use-module (gnu packages libffi) ;; python-cffi
  30. #:use-module (gnu packages llvm)
  31. #:use-module (gnu packages multiprecision)
  32. #:use-module (gnu packages nettle)
  33. #:use-module (gnu packages pkg-config)
  34. #:use-module (gnu packages python)
  35. #:use-module (gnu packages python-xyz) ;; python-setuptools
  36. #:use-module (gnu packages rust)
  37. #:use-module (gnu packages serialization)
  38. #:use-module (gnu packages sqlite)
  39. #:use-module (gnu packages tls))
  40. (define-public sequoia
  41. (package
  42. (name "sequoia")
  43. (version "1.1.0")
  44. (source
  45. (origin
  46. (method git-fetch)
  47. (uri (git-reference
  48. (url "https://gitlab.com/sequoia-pgp/sequoia.git")
  49. (commit (string-append "openpgp/v" version))))
  50. (sha256
  51. (base32 "0knkm0nw1h4ww51vks4jnnp1yc45llfi7j0i70f6vf2bcknnbmci"))
  52. (file-name (git-file-name name version))))
  53. (build-system cargo-build-system)
  54. (outputs '("out" "python"))
  55. (native-inputs
  56. `(("clang" ,clang)
  57. ("pkg-config" ,pkg-config)
  58. ("python-pytest" ,python-pytest)
  59. ("python-pytest-runner" ,python-pytest-runner)
  60. ("python-wrapper" ,python-wrapper)))
  61. (inputs
  62. `(("capnproto" ,capnproto)
  63. ("gmp" ,gmp)
  64. ("nettle" ,nettle)
  65. ("openssl" ,openssl)
  66. ("python" ,python)
  67. ("python-cffi" ,python-cffi)
  68. ("sqlite" ,sqlite)))
  69. (arguments
  70. `(#:tests? #f ;; building the tests requires 9.7GB total
  71. #:rust ,rust
  72. #:cargo-inputs
  73. (("rust-anyhow" ,rust-anyhow-1)
  74. ("rust-backtrace" ,rust-backtrace-0.3)
  75. ("rust-base64" ,rust-base64-0.13)
  76. ;;("rust-buffered-reader" included
  77. ("rust-bzip2" ,rust-bzip2-0.4)
  78. ("rust-capnp" ,rust-capnp-0.13)
  79. ("rust-capnp-rpc" ,rust-capnp-rpc-0.13)
  80. ("rust-capnpc" ,rust-capnpc-0.13)
  81. ("rust-chrono" ,rust-chrono-0.4) ;; for sqv, sop
  82. ("rust-clap" ,rust-clap-2) ;; for sqv
  83. ("rust-colored" ,rust-colored-1.9.1)
  84. ("rust-crossterm" ,rust-crossterm-0.13)
  85. ("rust-ctor" ,rust-ctor-0.1)
  86. ("rust-dirs" ,rust-dirs-2)
  87. ("rust-dyn-clone" ,rust-dyn-clone-1)
  88. ("rust-ed25519-dalek" ,rust-ed25519-dalek-1)
  89. ("rust-eax" ,rust-eax-0.3)
  90. ;;("rust-failure" included
  91. ("rust-filetime" ,rust-filetime-0.2)
  92. ("rust-flate2" ,rust-flate2-1)
  93. ("rust-fs2" ,rust-fs2-0.4)
  94. ("rust-futures" ,rust-futures-0.3)
  95. ("rust-futures-util" ,rust-futures-util-0.3)
  96. ("rust-http" ,rust-http-0.2)
  97. ("rust-hyper" ,rust-hyper-0.13)
  98. ("rust-hyper-tls" ,rust-hyper-tls-0.4)
  99. ("rust-idna" ,rust-idna-0.2)
  100. ("rust-itertools" ,rust-itertools-0.9) ;; for sq
  101. ("rust-lalrpop" ,rust-lalrpop-0.19)
  102. ("rust-lalrpop-util" ,rust-lalrpop-util-0.19)
  103. ("rust-lazy-static" ,rust-lazy-static-1)
  104. ("rust-libc" ,rust-libc-0.2)
  105. ("rust-memsec" ,rust-memsec-0.6)
  106. ("rust-native-tls" ,rust-native-tls-0.2)
  107. ("rust-nettle" ,rust-nettle-7)
  108. ("rust-num-bigint-dig" ,rust-num-bigint-dig-0.6)
  109. ("rust-parity-tokio-ipc" ,rust-parity-tokio-ipc-0.4)
  110. ("rust-percent-encoding" ,rust-percent-encoding-2)
  111. ("rust-prettytable-rs" ,rust-prettytable-rs-0.8) ;; for sq
  112. ("rust-proc-macro2" ,rust-proc-macro2-1)
  113. ("rust-quickcheck" ,rust-quickcheck-0.9)
  114. ("rust-rand" ,rust-rand-0.7)
  115. ("rust-regex" ,rust-regex-1)
  116. ("rust-rusqlite" ,rust-rusqlite-0.24)
  117. ("rust-sha1collisiondetection" ,rust-sha1collisiondetection-0.2)
  118. ("rust-socket2", rust-socket2-0.3)
  119. ("rust-structopt" ,rust-structopt-0.3) ;; for sop
  120. ("rust-tempfile" ,rust-tempfile-3) ;; for sq
  121. ("rust-thiserror" ,rust-thiserror-1)
  122. ("rust-tokio" ,rust-tokio-0.2)
  123. ("rust-tokio-core" ,rust-tokio-core-0.1)
  124. ("rust-unicode-normalization" ,rust-unicode-normalization-0.1)
  125. ("rust-url" ,rust-url-2)
  126. ("rust-win-crypto-ng" ,rust-win-crypto-ng-0.4)
  127. ("rust-winapi" ,rust-winapi-0.3)
  128. ("rust-zbase32" ,rust-zbase32-0.1))
  129. #:cargo-development-inputs
  130. (("rust-assert-cli" ,rust-assert-cli-0.6) ;; dev-dep for for sq, sqv
  131. ("rust-bindgen" ,rust-bindgen-0.51) ;; FIXME for nettle-sys and rusqlite
  132. ;;("rust-lalrpop" ,rust-lalrpop-0.19)
  133. ("rust-quickcheck" ,rust-quickcheck-0.9)
  134. ("rust-rand" ,rust-rand-0.7)
  135. ("rust-rpassword" ,rust-rpassword-5))
  136. #:phases
  137. (modify-phases %standard-phases
  138. ;; Run make instead of using the rust build system, as
  139. ;; suggested by the installation instructions
  140. (replace 'build (lambda _ (invoke "make" "build-release") #t))
  141. (delete 'package) ;; cargo can't package a multi-crate workspace
  142. (replace 'check
  143. (lambda* (#:key tests? #:allow-other-keys)
  144. (if tests?
  145. (invoke "make" "check")
  146. #t)))
  147. (replace 'install (lambda _ (invoke "make" "install") #t))
  148. (add-after 'unpack 'fix-rand-dependency
  149. (lambda _
  150. (substitute* "ipc/Cargo.toml"
  151. ;; required: enable rand::rngs::OsRng in rand >= 0.8
  152. (("(^rand =.*,) default-features = false(.*)" _ a b)
  153. (string-append a " features = [\"getrandom\"]" b)))
  154. #t))
  155. (add-after 'unpack 'fix-permissions
  156. (lambda _
  157. (chmod "sq/src/sq-usage.rs" #o644)
  158. (chmod "sqv/src/sqv-usage.rs" #o644)
  159. #t))
  160. (add-after 'unpack 'fix-environment
  161. (lambda* (#:key outputs #:allow-other-keys)
  162. ;; adjust prefix
  163. (setenv "PREFIX" (assoc-ref outputs "out"))
  164. ;; fix install script detection
  165. (setenv "INSTALL" "install")
  166. #t))
  167. (add-after 'unpack 'fix-fo-python-output
  168. (lambda* (#:key outputs #:allow-other-keys)
  169. (let ((out (assoc-ref outputs "out"))
  170. (pyout (assoc-ref outputs "python")))
  171. (substitute* "ffi/lang/python/Makefile"
  172. ;; adjust prefix for python package
  173. (("PREFIX\\s*\\??=.*")
  174. (string-append "PREFIX = " pyout "\n"))
  175. ;; fix rpath to include the main package
  176. (("\\WLDFLAGS=" text)
  177. (string-append text "'-Wl,-rpath=" out "/lib '"))
  178. ;; make setuptools install into the prefix, see
  179. ;; guix/build/python-build-system.scm for explanation
  180. (("\\ssetup.py\\s+install\\s")
  181. " setup.py install --root=/ --single-version-externally-managed "))
  182. #t)))
  183. (add-after 'unpack 'fix-pkgconfig-file-substitutes
  184. ;; preempt Makefiles replacing PREFIX by pwd
  185. (lambda* (#:key outputs #:allow-other-keys)
  186. (let ((out (assoc-ref outputs "out")))
  187. (substitute* "ffi/sequoia.pc.in"
  188. (("PREFIX") out))
  189. (substitute* "openpgp-ffi/sequoia-openpgp.pc.in"
  190. (("PREFIX") out))
  191. #t)))
  192. (add-after 'unpack 'keep-SOURCE_DATE_EPOCH
  193. (lambda _
  194. ;; preempt Makefiles replacing SOURCE_DATE_EPOCH
  195. (substitute* "Makefile"
  196. (("SOURCE_DATE_EPOCH\\s=" line)
  197. (string-append "#" line)))
  198. #t))
  199. (add-after 'unpack 'set-missing-env-vars
  200. (lambda* (#:key inputs #:allow-other-keys)
  201. ;; FIXME: why do we need to set this here?
  202. (setenv "LIBCLANG_PATH"
  203. (string-append (assoc-ref inputs "clang") "/lib"))
  204. #t))
  205. (add-after 'unpack 'unpin-deps
  206. (lambda _
  207. ;; As the comment in that file explains, upstream encourages
  208. ;; unpinning, as the pinned version is only to make sure the crate
  209. ;; compiles on older versions of rustc
  210. (substitute* '("openpgp/Cargo.toml" "sq/Cargo.toml")
  211. (("= \"=") "= \""))
  212. #t)))))
  213. (home-page "https://sequoia-pgp.org")
  214. (synopsis "New OpenPGP implementation")
  215. (description "Sequoia is a new OpenPGP implementation. It consists of
  216. several crates, providing both a low-level and a high-level API for dealing
  217. with OpenPGP data.")
  218. (license license:gpl2+)))