aboutsummaryrefslogtreecommitdiff
path: root/gnu/services/lirc.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services/lirc.scm')
-rw-r--r--gnu/services/lirc.scm83
1 files changed, 57 insertions, 26 deletions
diff --git a/gnu/services/lirc.scm b/gnu/services/lirc.scm
index 857f362db7..6ae622579d 100644
--- a/gnu/services/lirc.scm
+++ b/gnu/services/lirc.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -18,18 +19,65 @@
(define-module (gnu services lirc)
#:use-module (gnu services)
+ #:use-module (gnu services dmd)
#:use-module (gnu packages lirc)
- #:use-module (guix monads)
- #:use-module (guix store)
#:use-module (guix gexp)
+ #:use-module (guix records)
+ #:use-module (ice-9 match)
#:export (lirc-service))
;;; Commentary:
;;;
-;;; LIRC services.
+;;; LIRC service.
;;;
;;; Code:
+(define-record-type* <lirc-configuration>
+ lirc-configuration make-lirc-configuration
+ lirc-configuation?
+ (lirc lirc-configuration-lirc ;<package>
+ (default lirc))
+ (device lirc-configuration-device) ;string
+ (driver lirc-configuration-driver) ;string
+ (config-file lirc-configuration-file) ;string | file-like object
+ (extra-options lirc-configuration-options ;list of strings
+ (default '())))
+
+(define %lirc-activation
+ #~(begin
+ (use-modules (guix build utils))
+ (mkdir-p "/var/run/lirc")))
+
+(define lirc-dmd-service
+ (match-lambda
+ (($ <lirc-configuration> lirc device driver config-file options)
+ (list (dmd-service
+ (provision '(lircd))
+ (documentation "Run the LIRC daemon.")
+ (requirement '(user-processes))
+ (start #~(make-forkexec-constructor
+ (list (string-append #$lirc "/sbin/lircd")
+ "--nodaemon"
+ #$@(if device
+ #~("--device" #$device)
+ #~())
+ #$@(if driver
+ #~("--driver" #$driver)
+ #~())
+ #$@(if config-file
+ #~(#$config-file)
+ #~())
+ #$@options)))
+ (stop #~(make-kill-destructor)))))))
+
+(define lirc-service-type
+ (service-type (name 'lirc)
+ (extensions
+ (list (service-extension dmd-root-service-type
+ lirc-dmd-service)
+ (service-extension activation-service-type
+ (const %lirc-activation))))))
+
(define* (lirc-service #:key (lirc lirc)
device driver config-file
(extra-options '()))
@@ -41,28 +89,11 @@ The daemon will use specified @var{device}, @var{driver} and
Finally, @var{extra-options} is a list of additional command-line options
passed to @command{lircd}."
- (with-monad %store-monad
- (return
- (service
- (provision '(lircd))
- (documentation "Run the LIRC daemon.")
- (requirement '(user-processes))
- (start #~(make-forkexec-constructor
- (list (string-append #$lirc "/sbin/lircd")
- "--nodaemon"
- #$@(if device
- #~("--device" #$device)
- #~())
- #$@(if driver
- #~("--driver" #$driver)
- #~())
- #$@(if config-file
- #~(#$config-file)
- #~())
- #$@extra-options)))
- (stop #~(make-kill-destructor))
- (activate #~(begin
- (use-modules (guix build utils))
- (mkdir-p "/var/run/lirc")))))))
+ (service lirc-service-type
+ (lirc-configuration
+ (lirc lirc)
+ (device device) (driver driver)
+ (config-file config-file)
+ (extra-options extra-options))))
;;; lirc.scm ends here