projects/guix·blob java-team · refs

110 lines · 4.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015 Alex Kost <[email protected]>
3;;; Copyright © 2015, 2016, 2022 Ludovic Courtès <[email protected]>
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)
22 #:use-module (gnu services shepherd)
23 #:use-module (gnu packages lirc)
24 #:use-module (guix deprecation)
25 #:use-module (guix gexp)
26 #:use-module (guix records)
27 #:use-module (ice-9 match)
28 #:export (lirc-configuration
29 lirc-configuation?
30 lirc-service ; deprecated
31 lirc-service-type))
32
33;;; Commentary:
34;;;
35;;; LIRC service.
36;;;
37;;; Code:
38
39(define-record-type* <lirc-configuration>
40 lirc-configuration make-lirc-configuration
41 lirc-configuation?
42 (lirc lirc-configuration-lirc ;file-like
43 (default lirc))
44 (device lirc-configuration-device ;string
45 (default #f))
46 (driver lirc-configuration-driver ;string
47 (default #f))
48 (config-file lirc-configuration-file ;string | file-like object
49 (default #f))
50 (extra-options lirc-configuration-options ;list of strings
51 (default '())))
52
53(define %lirc-activation
54 #~(begin
55 (use-modules (guix build utils))
56 (mkdir-p "/var/run/lirc")))
57
58(define lirc-shepherd-service
59 (match-lambda
60 (($ <lirc-configuration> lirc device driver config-file options)
61 (list (shepherd-service
62 (provision '(lircd))
63 (documentation "Run the LIRC daemon.")
64 (requirement '(user-processes))
65 (start #~(make-forkexec-constructor
66 (list (string-append #$lirc "/sbin/lircd")
67 "--nodaemon"
68 #$@(if device
69 #~("--device" #$device)
70 #~())
71 #$@(if driver
72 #~("--driver" #$driver)
73 #~())
74 #$@(if config-file
75 #~(#$config-file)
76 #~())
77 #$@options)))
78 (stop #~(make-kill-destructor)))))))
79
80(define lirc-service-type
81 (service-type (name 'lirc)
82 (extensions
83 (list (service-extension shepherd-root-service-type
84 lirc-shepherd-service)
85 (service-extension activation-service-type
86 (const %lirc-activation))))
87 (description "Run LIRC, a daemon that decodes infrared signals
88from remote controls.")
89 (default-value (lirc-configuration))))
90
91(define-deprecated (lirc-service #:key (lirc lirc)
92 device driver config-file
93 (extra-options '()))
94 lirc-service-type
95 "Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
96decodes infrared signals from remote controls.
97
98The daemon will use specified @var{device}, @var{driver} and
99@var{config-file} (configuration file name).
100
101Finally, @var{extra-options} is a list of additional command-line options
102passed to @command{lircd}."
103 (service lirc-service-type
104 (lirc-configuration
105 (lirc lirc)
106 (device device) (driver driver)
107 (config-file config-file)
108 (extra-options extra-options))))
109
110;;; lirc.scm ends here