Commit | Line | Data |
---|---|---|
f9c04580 JN |
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 | |
7ccd471c JN |
28 | hurd-console-service-type |
29 | hurd-getty-configuration | |
30 | hurd-getty-service-type)) | |
f9c04580 JN |
31 | |
32 | ;;; Commentary: | |
33 | ;;; | |
34 | ;;; This module implements services for the Hurd. | |
35 | ;;; | |
36 | ;;; Code: | |
37 | ||
38 | ;;; | |
39 | ;;; The Hurd VGA console service. | |
40 | ;;; | |
41 | ||
42 | (define-record-type* <hurd-console-configuration> | |
43 | hurd-console-configuration make-hurd-console-configuration | |
44 | hurd-console-configuration? | |
45 | (hurd hurd-console-configuration-hurd ;package | |
46 | (default hurd))) | |
47 | ||
48 | (define (hurd-console-shepherd-service config) | |
49 | "Return a <shepherd-service> for a Hurd VGA console with CONFIG." | |
50 | ||
51 | (define console-command | |
52 | #~(list | |
53 | (string-append #$(hurd-console-configuration-hurd config) "/bin/console") | |
54 | "-c" "/dev/vcs" | |
55 | "-d" "vga" | |
56 | "-d" "pc_kbd" | |
57 | "-d" "generic_speaker")) | |
58 | ||
59 | (list (shepherd-service | |
60 | (documentation "Run the Hurd’s VGA console client.") | |
61 | (provision '(console)) | |
62 | (requirement '(user-processes)) | |
63 | (start #~(make-forkexec-constructor #$console-command)) | |
64 | (stop #~(make-kill-destructor))))) | |
65 | ||
66 | (define hurd-console-service-type | |
67 | (service-type | |
68 | (name 'console) | |
69 | (description "Run the Hurd console client.") | |
70 | (extensions | |
71 | (list (service-extension shepherd-root-service-type | |
72 | hurd-console-shepherd-service))) | |
73 | (default-value (hurd-console-configuration)))) | |
74 | ||
7ccd471c JN |
75 | \f |
76 | ;;; | |
77 | ;;; The Hurd getty service. | |
78 | ;;; | |
79 | ||
80 | (define-record-type* <hurd-getty-configuration> | |
81 | hurd-getty-configuration make-hurd-getty-configuration | |
82 | hurd-getty-configuration? | |
83 | (hurd hurd-getty-configuration-hurd ;<package> | |
84 | (default hurd)) | |
85 | (tty hurd-getty-configuration-tty) ;string | |
86 | (baud-rate hurd-getty-configuration-baud-rate | |
87 | (default 38400))) ;integer | |
88 | ||
89 | (define (hurd-getty-shepherd-service config) | |
90 | "Return a <shepherd-service> for a Hurd getty with CONFIG." | |
91 | ||
92 | (let ((hurd (hurd-getty-configuration-hurd config)) | |
93 | (tty (hurd-getty-configuration-tty config)) | |
94 | (baud-rate (hurd-getty-configuration-baud-rate config))) | |
95 | ||
96 | (define getty-command | |
97 | #~(list | |
98 | (string-append #$hurd "/libexec/getty") | |
99 | #$(number->string baud-rate) | |
100 | #$tty)) | |
101 | ||
102 | (list | |
103 | (shepherd-service | |
104 | (documentation "Run getty on a tty.") | |
105 | (provision (list (string->symbol (string-append "term-" tty)))) | |
106 | (requirement '(user-processes console)) | |
107 | (start #~(make-forkexec-constructor #$getty-command)) | |
108 | (stop #~(make-kill-destructor)))))) | |
109 | ||
110 | (define hurd-getty-service-type | |
111 | (service-type | |
112 | (name 'getty) | |
113 | (extensions (list (service-extension shepherd-root-service-type | |
114 | hurd-getty-shepherd-service))) | |
115 | (description | |
116 | "Provide console login using the Hurd @command{getty} program."))) | |
117 | ||
f9c04580 | 118 | ;;; hurd.scm ends here |