projects/guix·blob ruby-team · refs

83 lines · 3.4 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 spice-vdagent-service)) ; deprecated
31
32(define-record-type* <spice-vdagent-configuration>
33 spice-vdagent-configuration make-spice-vdagent-configuration
34 spice-vdagent-configuration?
35 (spice-vdagent spice-vdagent-configuration-spice-vdagent
36 (default spice-vdagent)))
37
38(define (spice-vdagent-shepherd-service config)
39 "Return a <shepherd-service> for spice-vdagentd with CONFIG."
40 (define spice-vdagent (spice-vdagent-configuration-spice-vdagent config))
41
42 (define spice-vdagentd-command
43 (list
44 (file-append spice-vdagent "/sbin/spice-vdagentd")
45 "-x"))
46
47 (list
48 (shepherd-service
49 (documentation "Spice vdagentd service")
50 (requirement '(user-processes dbus-system))
51 (provision '(spice-vdagentd))
52 (start #~(lambda args
53 ;; spice-vdagentd supports being activated upon the client
54 ;; connecting to its socket; when not using such feature, the
55 ;; socket should not exist before vdagentd creates it itself.
56 (mkdir-p "/run/spice-vdagentd")
57 (false-if-exception
58 (delete-file "/run/spice-vdagentd/spice-vdagent-sock"))
59 (fork+exec-command '#$spice-vdagentd-command)))
60 (stop #~(make-kill-destructor)))))
61
62(define spice-vdagent-profile
63 (compose list spice-vdagent-configuration-spice-vdagent))
64
65(define spice-vdagent-service-type
66 (service-type
67 (name 'spice-vdagent)
68 (default-value (spice-vdagent-configuration))
69 (extensions
70 (list (service-extension shepherd-root-service-type
71 spice-vdagent-shepherd-service)
72 (service-extension profile-service-type
73 spice-vdagent-profile)))
74 (description "Start the @command{vdagentd} and @command{vdagent} daemons
75from the @code{spice-vdagent} package to enable window resizing and clipboard
76sharing for @acronym{VM, virtual machine} guests.")))
77
78(define-deprecated (spice-vdagent-service
79 #:optional (config (spice-vdagent-configuration)))
80 "Start the @command{vdagentd} and @command{vdagent} daemons
81from @var{spice-vdagent} to enable guest window resizing and
82clipboard sharing."
83 (service spice-vdagent-service-type config))