services: cuirass: Cache defaults to /var/cache/cuirass.
[jackhill/guix/guix.git] / gnu / services / spice.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 David Craven <david@craven.ch>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu services spice)
20 #:use-module (gnu packages spice)
21 #:use-module (gnu services)
22 #:use-module (gnu services shepherd)
23 #:use-module (guix gexp)
24 #:use-module (guix records)
25 #:export (spice-vdagent-configuration
26 spice-vdagent-configuration?
27 spice-vdagent-service-type
28 spice-vdagent-service))
29
30 (define-record-type* <spice-vdagent-configuration>
31 spice-vdagent-configuration make-spice-vdagent-configuration
32 spice-vdagent-configuration?
33 (spice-vdagent spice-vdagent-configuration-spice-vdagent
34 (default spice-vdagent)))
35
36 (define (spice-vdagent-activation config)
37 "Return the activation gexp for CONFIG."
38 #~(mkdir-p "/var/run/spice-vdagentd"))
39
40 (define (spice-vdagent-shepherd-service config)
41 "Return a <shepherd-service> for spice-vdagentd with CONFIG."
42 (define spice-vdagent (spice-vdagent-configuration-spice-vdagent config))
43
44 (define spice-vdagentd-command
45 (list
46 (file-append spice-vdagent "/sbin/spice-vdagentd")
47 "-x"))
48
49 (list
50 (shepherd-service
51 (documentation "Spice vdagentd service")
52 (requirement '(udev))
53 (provision '(spice-vdagentd))
54 (start #~(make-forkexec-constructor #$@spice-vdagentd-command))
55 (stop #~(make-kill-destructor)))))
56
57 (define spice-vdagent-profile
58 (compose list spice-vdagent-configuration-spice-vdagent))
59
60 (define spice-vdagent-service-type
61 (service-type (name 'spice-vdagent)
62 (extensions
63 (list (service-extension shepherd-root-service-type
64 spice-vdagent-shepherd-service)
65 (service-extension activation-service-type
66 spice-vdagent-activation)
67 (service-extension profile-service-type
68 spice-vdagent-profile)))))
69
70 (define* (spice-vdagent-service
71 #:optional (config (spice-vdagent-configuration)))
72 "Start the @command{vdagentd} and @command{vdagent} deamons
73 from @var{spice-vdagent} to enable guest window resizing and
74 clipboard sharing."
75 (service spice-vdagent-service-type config))