services: Add `hurd-console-service-type'.
[jackhill/guix/guix.git] / gnu / services / hurd.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
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 hurd)
20 #:use-module (gnu packages admin)
21 #:use-module (gnu packages hurd)
22 #:use-module (gnu services)
23 #:use-module (gnu services shepherd)
24 #:use-module (gnu system)
25 #:use-module (guix gexp)
26 #:use-module (guix records)
27 #:export (hurd-console-configuration
28 hurd-console-service-type))
29
30 ;;; Commentary:
31 ;;;
32 ;;; This module implements services for the Hurd.
33 ;;;
34 ;;; Code:
35
36 ;;;
37 ;;; The Hurd VGA console service.
38 ;;;
39
40 (define-record-type* <hurd-console-configuration>
41 hurd-console-configuration make-hurd-console-configuration
42 hurd-console-configuration?
43 (hurd hurd-console-configuration-hurd ;package
44 (default hurd)))
45
46 (define (hurd-console-shepherd-service config)
47 "Return a <shepherd-service> for a Hurd VGA console with CONFIG."
48
49 (define console-command
50 #~(list
51 (string-append #$(hurd-console-configuration-hurd config) "/bin/console")
52 "-c" "/dev/vcs"
53 "-d" "vga"
54 "-d" "pc_kbd"
55 "-d" "generic_speaker"))
56
57 (list (shepherd-service
58 (documentation "Run the Hurd’s VGA console client.")
59 (provision '(console))
60 (requirement '(user-processes))
61 (start #~(make-forkexec-constructor #$console-command))
62 (stop #~(make-kill-destructor)))))
63
64 (define hurd-console-service-type
65 (service-type
66 (name 'console)
67 (description "Run the Hurd console client.")
68 (extensions
69 (list (service-extension shepherd-root-service-type
70 hurd-console-shepherd-service)))
71 (default-value (hurd-console-configuration))))
72
73 ;;; hurd.scm ends here