unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] services: Add rngd service.
@ 2016-07-03  0:16 David Craven
  2016-07-03  1:42 ` Leo Famulari
  0 siblings, 1 reply; 12+ messages in thread
From: David Craven @ 2016-07-03  0:16 UTC (permalink / raw)
  To: guix-devel; +Cc: david

* gnu/services/base.scm (rngd-service): New service.
* gnu/packages/linux.scm (rng-tools): New package.
---
 gnu/packages/linux.scm | 76 +++++++++++++++++++++++++++++++-------------------
 gnu/services/base.scm  | 43 ++++++++++++++++++++++++++--
 2 files changed, 89 insertions(+), 30 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index a0c21d8..f1b2172 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -30,49 +30,49 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages linux)
-  #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages algebra)
+  #:use-module (gnu packages attr)
+  #:use-module (gnu packages autotools)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bison)
+  #:use-module (gnu packages calendar)
+  #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
-  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages docbook)
+  #:use-module (gnu packages documentation)
+  #:use-module (gnu packages elf)
   #:use-module (gnu packages flex)
-  #:use-module (gnu packages bison)
-  #:use-module (gnu packages admin)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages gettext)
+  #:use-module (gnu packages glib)
   #:use-module (gnu packages gperf)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages libusb)
+  #:use-module (gnu packages maths)
   #:use-module (gnu packages ncurses)
-  #:use-module (gnu packages pciutils)
-  #:use-module (gnu packages databases)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages pciutils)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages rrdtool)
   #:use-module (gnu packages slang)
-  #:use-module (gnu packages algebra)
-  #:use-module (gnu packages gettext)
-  #:use-module (gnu packages glib)
-  #:use-module (gnu packages pulseaudio)
-  #:use-module (gnu packages attr)
-  #:use-module (gnu packages xml)
-  #:use-module (gnu packages autotools)
   #:use-module (gnu packages texinfo)
-  #:use-module (gnu packages check)
-  #:use-module (gnu packages maths)
-  #:use-module (gnu packages base)
-  #:use-module (gnu packages rrdtool)
-  #:use-module (gnu packages elf)
-  #:use-module (gnu packages gtk)
-  #:use-module (gnu packages docbook)
-  #:use-module (gnu packages documentation)
-  #:use-module (gnu packages readline)
-  #:use-module (gnu packages calendar)
   #:use-module (gnu packages tls)
-  #:use-module (gnu packages freedesktop)
-  #:use-module (guix packages)
-  #:use-module (guix download)
-  #:use-module (guix utils)
-  #:use-module (guix build-system gnu)
+  #:use-module (gnu packages xml)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
+  #:use-module (guix download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
   #:use-module (srfi srfi-26)
@@ -2726,3 +2726,23 @@ from userspace.")
 commonly found on Microsoft Windows.  It is implemented as a FUSE file system.
 The package provides additional NTFS tools.")
     (license license:gpl2+)))
+
+(define-public rng-tools
+  (package
+    (name "rng-tools")
+    (version "5")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                "http://downloads.sourceforge.net/sourceforge/gkernel/rng-tools-" version
+                ".tar.gz"))
+              (sha256
+                (base32
+                  "13h7lc8wl9khhvkr0i3bl5j9bapf8anhqis1lcnwxg1vc2v058b0"))))
+    (build-system gnu-build-system)
+    (synopsis "Random number generator daemon")
+    (description
+     "Monitor a hardware random number generator, and supply entropy
+from that to the system kernel's /dev/random machinery.")
+    (home-page "http://sourceforge.net/projects/gkernel")
+    (license license:gpl2)))
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 2780d12..fab287a 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -31,7 +31,7 @@
   #:use-module (gnu system mapped-devices)
   #:use-module (gnu packages admin)
   #:use-module ((gnu packages linux)
-                #:select (eudev kbd e2fsprogs lvm2 fuse alsa-utils crda gpm))
+                #:select (alsa-utils crda eudev e2fsprogs fuse gpm kbd lvm2 rng-tools))
   #:use-module ((gnu packages base)
                 #:select (canonical-package glibc))
   #:use-module (gnu packages package-management)
@@ -95,6 +95,7 @@
             gpm-service
 
             urandom-seed-service
+            rngd-service
 
             %base-services))
 
@@ -484,7 +485,45 @@ stopped before 'kill' is called."
 (define (urandom-seed-service)
   (service urandom-seed-service-type #f))
 
-\f
+
+;;;
+;;; Add hardware random number generator to entropy pool
+;;;
+
+(define-record-type* <rngd-configuration>
+  rngd-configuration make-rngd-configuration
+  rngd-configuration?
+  (rng-tools rngd-configuration-rng-tools)
+  (rng-device rngd-configuration-rngd-device))
+
+(define rngd-service-type
+  (shepherd-service-type
+    'rngd
+    (lambda (config)
+      (define rng-tools (rngd-configuration-rng-tools config))
+      (define rng-device (rngd-configuration-rngd-device config))
+
+      (define rngd-command
+        (list #~(string-append #$rng-tools "/sbin/rngd") "-f" "-r" rng-device))
+
+      (shepherd-service
+        (documentation "Add TRNG to entropy pool.")
+        (requirement '(udev))
+        (provision '(trng))
+        (start #~(make-forkexec-constructor #$@rngd-command))
+        (stop #~(make-kill-destructor))))))
+
+(define* (rngd-service #:key
+  (rng-tools rng-tools)
+  (rng-device "/dev/hwrng"))
+  "Run the @command{rngd} program from @var{rng-tools} to add @var{rng-device}
+to the kernel's entropy pool."
+  (service rngd-service-type
+    (rngd-configuration
+      (rng-tools rng-tools)
+      (rng-device rng-device))))
+
+
 ;;;
 ;;; System-wide environment variables.
 ;;;
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-07-05  9:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-03  0:16 [PATCH] services: Add rngd service David Craven
2016-07-03  1:42 ` Leo Famulari
2016-07-03  2:05   ` [PATCH 1/3] gnu: Reorder imports alphabetically David Craven
2016-07-03 21:31     ` Leo Famulari
2016-07-03 21:50       ` David Craven
2016-07-03  2:21   ` [PATCH] services: Add rngd service David Craven
2016-07-03  2:26   ` [PATCH 2/3] gnu: Add rng-tools 5 David Craven
2016-07-03 21:31     ` Leo Famulari
2016-07-03  2:26   ` [PATCH 3/3] services: Add rngd-service David Craven
2016-07-03 18:25   ` [PATCH 3/4] " David Craven
2016-07-05  9:11     ` Ludovic Courtès
2016-07-03 18:25   ` [PATCH 4/4] build: Ignore texi2pdf temporary files David Craven

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).