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