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.scm80
1 files changed, 57 insertions, 23 deletions
diff --git a/gnu/services/lirc.scm b/gnu/services/lirc.scm
index 368f2ba293..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,17 +19,65 @@
(define-module (gnu services lirc)
#:use-module (gnu services)
+ #:use-module (gnu services dmd)
#:use-module (gnu packages lirc)
- #: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 '()))
@@ -40,26 +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}."
- (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