Subject: [PATCH 05/34] gnu: Add ruby-rbnacl.

From: Christopher Baines <[email-masked]>
Date: Sun, 17 Feb 2019 19:22:45 +0000

* gnu/packages/ruby.scm (ruby-rbnacl): New variable.
---
 gnu/packages/ruby.scm | 56 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gnu/packages/ruby.scm b/gnu/packages/ruby.scm
index 9bcdbec4fd..b17a03e7cc 100644
--- a/gnu/packages/ruby.scm
+++ b/gnu/packages/ruby.scm
@@ -35,6 +35,7 @@
   #:use-module (gnu packages base)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages crypto)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages dbm)
   #:use-module (gnu packages rails)
@@ -1336,6 +1337,61 @@ same log file.")
     (home-page "https://github.com/bdurand/lumberjack")
     (license license:expat)))
 
+(define-public ruby-rbnacl
+  (package
+    (name "ruby-rbnacl")
+    (version "6.0.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (rubygems-uri "rbnacl" version))
+       (sha256
+        (base32
+         "0ajxy5kj2jw09wdsla3jmha8w07vj5l14288xr9djpl327g3lzhn"))))
+    (build-system ruby-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'remove-unnecessary-dependencies
+           (lambda _
+             ;; Coveralls relates to a network service, and Rubocop to code
+             ;; linting and both are unnecessary to run the tests
+             (substitute* "Gemfile"
+               ((".*rubocop.*") "\n")
+               ((".*guard-rspec.*") "\n")
+               ((".*coveralls.*") "\n"))
+             (substitute* "spec/spec_helper.rb"
+               (("require \"coveralls\"") "")
+               (("Coveralls.wear!") ""))))
+         (add-after 'unpack 'use-libsodium-from-store
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* '("lib/rbnacl/init.rb"
+                            "lib/rbnacl/sodium.rb")
+               (("\"sodium\", \"libsodium\\.so\\.18\", \"libsodium\\.so\\.23\"")
+                (string-append "\""
+                               (assoc-ref inputs "libsodium") "/lib/libsodium.so"
+                               "\"")))))
+         ;; Run Rspec directly to avoid the Rubocop dependency in the Rakefile
+         (replace 'check
+           (lambda* (#:key tests? #:allow-other-keys)
+             (when tests?
+               (invoke "rspec"))
+             #t)))))
+    (propagated-inputs
+     `(("ruby-ffi" ,ruby-ffi)))
+    (inputs
+     `(("libsodium" ,libsodium)))
+    (native-inputs
+     `(("bundler" ,bundler)
+       ("ruby-rspec" ,ruby-rspec)))
+    (synopsis "Ruby FFI binding to libsodium")
+    (description
+     "This package provides Ruby FFI bindings to the Networking and
+Cryptography (NaCl) library, also known as libsodium.  This provides a
+high-level toolkit for building cryptographic systems and protocols.")
+    (home-page "https://github.com/crypto-rb/rbnacl")
+    (license license:expat)))
+
 (define-public ruby-nenv
   (package
     (name "ruby-nenv")
-- 
2.20.1