services: guix-publish: Add zstd compression by default.
[jackhill/guix/guix.git] / gnu / services / lirc.scm
CommitLineData
aa4ed923
AK
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
24e96431 3;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org>
aa4ed923
AK
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu services lirc)
21 #:use-module (gnu services)
0190c1c0 22 #:use-module (gnu services shepherd)
aa4ed923 23 #:use-module (gnu packages lirc)
aa4ed923 24 #:use-module (guix gexp)
0adfe95a
LC
25 #:use-module (guix records)
26 #:use-module (ice-9 match)
24e96431
27 #:export (lirc-configuration
28 lirc-configuation?
29 lirc-service
30 lirc-service-type))
aa4ed923
AK
31
32;;; Commentary:
33;;;
0adfe95a 34;;; LIRC service.
aa4ed923
AK
35;;;
36;;; Code:
37
0adfe95a
LC
38(define-record-type* <lirc-configuration>
39 lirc-configuration make-lirc-configuration
40 lirc-configuation?
41 (lirc lirc-configuration-lirc ;<package>
42 (default lirc))
43 (device lirc-configuration-device) ;string
44 (driver lirc-configuration-driver) ;string
45 (config-file lirc-configuration-file) ;string | file-like object
46 (extra-options lirc-configuration-options ;list of strings
47 (default '())))
48
49(define %lirc-activation
50 #~(begin
51 (use-modules (guix build utils))
52 (mkdir-p "/var/run/lirc")))
53
d4053c71 54(define lirc-shepherd-service
0adfe95a
LC
55 (match-lambda
56 (($ <lirc-configuration> lirc device driver config-file options)
d4053c71 57 (list (shepherd-service
0adfe95a
LC
58 (provision '(lircd))
59 (documentation "Run the LIRC daemon.")
60 (requirement '(user-processes))
61 (start #~(make-forkexec-constructor
62 (list (string-append #$lirc "/sbin/lircd")
63 "--nodaemon"
64 #$@(if device
65 #~("--device" #$device)
66 #~())
67 #$@(if driver
68 #~("--driver" #$driver)
69 #~())
70 #$@(if config-file
71 #~(#$config-file)
72 #~())
73 #$@options)))
74 (stop #~(make-kill-destructor)))))))
75
76(define lirc-service-type
77 (service-type (name 'lirc)
78 (extensions
d4053c71
AK
79 (list (service-extension shepherd-root-service-type
80 lirc-shepherd-service)
0adfe95a
LC
81 (service-extension activation-service-type
82 (const %lirc-activation))))))
83
aa4ed923
AK
84(define* (lirc-service #:key (lirc lirc)
85 device driver config-file
86 (extra-options '()))
87 "Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
88decodes infrared signals from remote controls.
89
90The daemon will use specified @var{device}, @var{driver} and
91@var{config-file} (configuration file name).
92
93Finally, @var{extra-options} is a list of additional command-line options
94passed to @command{lircd}."
0adfe95a
LC
95 (service lirc-service-type
96 (lirc-configuration
97 (lirc lirc)
98 (device device) (driver driver)
99 (config-file config-file)
100 (extra-options extra-options))))
aa4ed923
AK
101
102;;; lirc.scm ends here