spice.scm 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016 David Craven <david@craven.ch>
  3. ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
  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. (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. (define-record-type* <spice-vdagent-configuration>
  30. spice-vdagent-configuration make-spice-vdagent-configuration
  31. spice-vdagent-configuration?
  32. (spice-vdagent spice-vdagent-configuration-spice-vdagent
  33. (default spice-vdagent)))
  34. (define (spice-vdagent-shepherd-service config)
  35. "Return a <shepherd-service> for spice-vdagentd with CONFIG."
  36. (define spice-vdagent (spice-vdagent-configuration-spice-vdagent config))
  37. (define spice-vdagentd-command
  38. (list
  39. (file-append spice-vdagent "/sbin/spice-vdagentd")
  40. "-x"))
  41. (list
  42. (shepherd-service
  43. (documentation "Spice vdagentd service")
  44. (requirement '(dbus-system))
  45. (provision '(spice-vdagentd))
  46. (start #~(lambda args
  47. ;; spice-vdagentd supports being activated upon the client
  48. ;; connecting to its socket; when not using such feature, the
  49. ;; socket should not exist before vdagentd creates it itself.
  50. (mkdir-p "/run/spice-vdagentd")
  51. (false-if-exception
  52. (delete-file "/run/spice-vdagentd/spice-vdagent-sock"))
  53. (fork+exec-command '#$spice-vdagentd-command)))
  54. (stop #~(make-kill-destructor)))))
  55. (define spice-vdagent-profile
  56. (compose list spice-vdagent-configuration-spice-vdagent))
  57. (define spice-vdagent-service-type
  58. (service-type
  59. (name 'spice-vdagent)
  60. (default-value (spice-vdagent-configuration))
  61. (extensions
  62. (list (service-extension shepherd-root-service-type
  63. spice-vdagent-shepherd-service)
  64. (service-extension profile-service-type
  65. spice-vdagent-profile)))))
  66. (define* (spice-vdagent-service
  67. #:optional (config (spice-vdagent-configuration)))
  68. "Start the @command{vdagentd} and @command{vdagent} daemons
  69. from @var{spice-vdagent} to enable guest window resizing and
  70. clipboard sharing."
  71. (service spice-vdagent-service-type config))