services: 'references-file' depends on Guile-Gcrypt.
[jackhill/guix/guix.git] / gnu / services / spice.scm
CommitLineData
00f46905
DC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 David Craven <david@craven.ch>
e57bd0be 3;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
00f46905
DC
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 gexp)
25 #:use-module (guix records)
26 #:export (spice-vdagent-configuration
27 spice-vdagent-configuration?
28 spice-vdagent-service-type
29 spice-vdagent-service))
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-activation config)
38 "Return the activation gexp for CONFIG."
e57bd0be
CL
39 #~(begin
40 (use-modules (guix build utils))
41 (mkdir-p "/var/run/spice-vdagentd")))
00f46905
DC
42
43(define (spice-vdagent-shepherd-service config)
44 "Return a <shepherd-service> for spice-vdagentd with CONFIG."
45 (define spice-vdagent (spice-vdagent-configuration-spice-vdagent config))
46
47 (define spice-vdagentd-command
48 (list
9e41130b 49 (file-append spice-vdagent "/sbin/spice-vdagentd")
00f46905
DC
50 "-x"))
51
52 (list
53 (shepherd-service
54 (documentation "Spice vdagentd service")
55 (requirement '(udev))
56 (provision '(spice-vdagentd))
7d903d2f 57 (start #~(make-forkexec-constructor '#$spice-vdagentd-command))
00f46905
DC
58 (stop #~(make-kill-destructor)))))
59
60(define spice-vdagent-profile
61 (compose list spice-vdagent-configuration-spice-vdagent))
62
63(define spice-vdagent-service-type
64 (service-type (name 'spice-vdagent)
65 (extensions
66 (list (service-extension shepherd-root-service-type
67 spice-vdagent-shepherd-service)
68 (service-extension activation-service-type
69 spice-vdagent-activation)
70 (service-extension profile-service-type
71 spice-vdagent-profile)))))
72
73(define* (spice-vdagent-service
74 #:optional (config (spice-vdagent-configuration)))
9a5edd02 75 "Start the @command{vdagentd} and @command{vdagent} daemons
00f46905
DC
76from @var{spice-vdagent} to enable guest window resizing and
77clipboard sharing."
78 (service spice-vdagent-service-type config))