spice.scm 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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-activation config)
  35. "Return the activation gexp for CONFIG."
  36. #~(begin
  37. (use-modules (guix build utils))
  38. (mkdir-p "/var/run/spice-vdagentd")))
  39. (define (spice-vdagent-shepherd-service config)
  40. "Return a <shepherd-service> for spice-vdagentd with CONFIG."
  41. (define spice-vdagent (spice-vdagent-configuration-spice-vdagent config))
  42. (define spice-vdagentd-command
  43. (list
  44. (file-append spice-vdagent "/sbin/spice-vdagentd")
  45. "-x"))
  46. (list
  47. (shepherd-service
  48. (documentation "Spice vdagentd service")
  49. (requirement '(udev))
  50. (provision '(spice-vdagentd))
  51. (start #~(make-forkexec-constructor #$@spice-vdagentd-command))
  52. (stop #~(make-kill-destructor)))))
  53. (define spice-vdagent-profile
  54. (compose list spice-vdagent-configuration-spice-vdagent))
  55. (define spice-vdagent-service-type
  56. (service-type (name 'spice-vdagent)
  57. (extensions
  58. (list (service-extension shepherd-root-service-type
  59. spice-vdagent-shepherd-service)
  60. (service-extension activation-service-type
  61. spice-vdagent-activation)
  62. (service-extension profile-service-type
  63. spice-vdagent-profile)))))
  64. (define* (spice-vdagent-service
  65. #:optional (config (spice-vdagent-configuration)))
  66. "Start the @command{vdagentd} and @command{vdagent} deamons
  67. from @var{spice-vdagent} to enable guest window resizing and
  68. clipboard sharing."
  69. (service spice-vdagent-service-type config))