summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-06-23 15:35:03 +0200
committerLudovic Courtès <ludo@gnu.org>2014-06-24 00:20:01 +0200
commit151a2c07aa0537c136e6fe61609957878f0a4c72 (patch)
treebe7eda5fab46c41b0a5488c69f508943d5ab6c06 /gnu/services
parent1bd3f8498632416fd87be737769a20bfc37f5602 (diff)
downloadpatches-151a2c07aa0537c136e6fe61609957878f0a4c72.tar
patches-151a2c07aa0537c136e6fe61609957878f0a4c72.tar.gz
services: Add udev service, and add it to '%base-services'.
* gnu/services/base.scm (udev-service): New procedure. (%base-services): Use it. * gnu/system.scm (%base-packages): Add UDEV.
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/base.scm32
1 files changed, 31 insertions, 1 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 595cac254b..35e5d42fa8 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -23,6 +23,8 @@
#:use-module (gnu system shadow) ; 'user-account', etc.
#:use-module (gnu system linux) ; 'pam-service', etc.
#:use-module (gnu packages admin)
+ #:use-module ((gnu packages linux)
+ #:select (udev))
#:use-module ((gnu packages base)
#:select (glibc-final))
#:use-module (gnu packages package-management)
@@ -35,6 +37,7 @@
file-system-service
user-processes-service
host-name-service
+ udev-service
mingetty-service
nscd-service
syslog-service
@@ -397,6 +400,32 @@ hydra.gnu.org are used by default."
(id 30000))))
(activate activate)))))
+(define* (udev-service #:key (udev udev))
+ "Run @var{udev}, which populates the @file{/dev} directory dynamically."
+ (with-monad %store-monad
+ (return (service
+ (provision '(udev))
+ (requirement '(root-file-system))
+ (documentation "Populate the /dev directory.")
+ (start #~(lambda ()
+ (let ((pid (primitive-fork)))
+ (case pid
+ ((0)
+ ;; In dmd 0.1, file descriptor 0 is closed, thus
+ ;; is gets reused when open(2) is called, and it
+ ;; turns out that EPOLL_CTL_ADD of 0 returns
+ ;; EPERM for some reason. So make sure 0 is
+ ;; open.
+ ;; FIXME: Close the other descriptors.
+ (execl (string-append #$udev "/libexec/udev/udevd")
+ "udevd"))
+ (else
+ ;; Create a bunch of devices.
+ (system* (string-append #$udev "/bin/udevadm")
+ "trigger")
+ pid)))))
+ (stop #~(make-kill-destructor))))))
+
(define %base-services
;; Convenience variable holding the basic services.
(let ((motd (text-file "motd" "
@@ -409,6 +438,7 @@ This is the GNU operating system, welcome!\n\n")))
(mingetty-service "tty6" #:motd motd)
(syslog-service)
(guix-service)
- (nscd-service))))
+ (nscd-service)
+ (udev-service))))
;;; base.scm ends here