games.scm 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
  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. (define-module (gnu services games)
  19. #:use-module (gnu services)
  20. #:use-module (gnu services shepherd)
  21. #:use-module (gnu packages admin)
  22. #:use-module (gnu packages games)
  23. #:use-module (gnu system shadow)
  24. #:use-module (guix gexp)
  25. #:use-module (guix modules)
  26. #:use-module (guix records)
  27. #:use-module (ice-9 match)
  28. #:export (wesnothd-configuration
  29. wesnothd-configuration?
  30. wesnothd-service-type))
  31. ;;;
  32. ;;; The Battle for Wesnoth server
  33. ;;;
  34. (define-record-type* <wesnothd-configuration>
  35. wesnothd-configuration make-wesnothd-configuration wesnothd-configuration?
  36. (package wesnothd-configuration-package
  37. (default wesnoth-server))
  38. (port wesnothd-configuration-port
  39. (default 15000)))
  40. (define %wesnothd-accounts
  41. (list (user-account
  42. (name "wesnothd")
  43. (group "wesnothd")
  44. (system? #t)
  45. (comment "Wesnoth daemon user")
  46. (home-directory "/var/empty")
  47. (shell (file-append shadow "/sbin/nologin")))
  48. (user-group
  49. (name "wesnothd")
  50. (system? #t))))
  51. (define wesnothd-shepherd-service
  52. (match-lambda
  53. (($ <wesnothd-configuration> package port)
  54. (with-imported-modules (source-module-closure
  55. '((gnu build shepherd)))
  56. (shepherd-service
  57. (documentation "The Battle for Wesnoth server")
  58. (provision '(wesnoth-daemon))
  59. (requirement '(networking))
  60. (modules '((gnu build shepherd)))
  61. (start #~(make-forkexec-constructor/container
  62. (list #$(file-append package "/bin/wesnothd")
  63. "-p" #$(number->string port))
  64. #:user "wesnothd" #:group "wesnothd"))
  65. (stop #~(make-kill-destructor)))))))
  66. (define wesnothd-service-type
  67. (service-type
  68. (name 'wesnothd)
  69. (description
  70. "Run The Battle for Wesnoth server @command{wesnothd}.")
  71. (extensions
  72. (list (service-extension account-service-type
  73. (const %wesnothd-accounts))
  74. (service-extension shepherd-root-service-type
  75. (compose list wesnothd-shepherd-service))))
  76. (default-value (wesnothd-configuration))))