all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Craven <david@craven.ch>
To: guix-devel@gnu.org
Cc: david@craven.ch
Subject: [PATCH] services: Add rngd service.
Date: Sun,  3 Jul 2016 02:16:23 +0200	[thread overview]
Message-ID: <20160703001623.27550-1-david@craven.ch> (raw)

* 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

             reply	other threads:[~2016-07-03  0:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-03  0:16 David Craven [this message]
2016-07-03  1:42 ` [PATCH] services: Add rngd service 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160703001623.27550-1-david@craven.ch \
    --to=david@craven.ch \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.