projects/guix·blob javascript-team · refs

75 lines · 3.0 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 David Craven <[email protected]>
3;;; Copyright © 2017 Clément Lassieur <[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 spice)
21 #:use-module (gnu packages spice)
22 #:use-module (gnu services)
23 #:use-module (gnu services shepherd)
24 #:use-module (guix deprecation)
25 #:use-module (guix gexp)
26 #:use-module (guix records)
27 #:export (spice-vdagent-configuration
28 spice-vdagent-configuration?
29 spice-vdagent-service-type))
30
31(define-record-type* <spice-vdagent-configuration>
32 spice-vdagent-configuration make-spice-vdagent-configuration
33 spice-vdagent-configuration?
34 (spice-vdagent spice-vdagent-configuration-spice-vdagent
35 (default spice-vdagent)))
36
37(define (spice-vdagent-shepherd-service config)
38 "Return a <shepherd-service> for spice-vdagentd with CONFIG."
39 (define spice-vdagent (spice-vdagent-configuration-spice-vdagent config))
40
41 (define spice-vdagentd-command
42 (list
43 (file-append spice-vdagent "/sbin/spice-vdagentd")
44 "-x"))
45
46 (list
47 (shepherd-service
48 (documentation "Spice vdagentd service")
49 (requirement '(user-processes dbus-system))
50 (provision '(spice-vdagentd))
51 (start #~(lambda args
52 ;; spice-vdagentd supports being activated upon the client
53 ;; connecting to its socket; when not using such feature, the
54 ;; socket should not exist before vdagentd creates it itself.
55 (mkdir-p "/run/spice-vdagentd")
56 (false-if-exception
57 (delete-file "/run/spice-vdagentd/spice-vdagent-sock"))
58 (fork+exec-command '#$spice-vdagentd-command)))
59 (stop #~(make-kill-destructor)))))
60
61(define spice-vdagent-profile
62 (compose list spice-vdagent-configuration-spice-vdagent))
63
64(define spice-vdagent-service-type
65 (service-type
66 (name 'spice-vdagent)
67 (default-value (spice-vdagent-configuration))
68 (extensions
69 (list (service-extension shepherd-root-service-type
70 spice-vdagent-shepherd-service)
71 (service-extension profile-service-type
72 spice-vdagent-profile)))
73 (description "Start the @command{vdagentd} and @command{vdagent} daemons
74from the @code{spice-vdagent} package to enable window resizing and clipboard
75sharing for @acronym{VM, virtual machine} guests.")))