projects/guix·blob python-team · refs

154 lines · 4.9 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <[email protected]>
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;;; Commentary:
20;;;
21;;; This module implements services for the Hurd.
22;;;
23;;; Code:
24
25(define-module (gnu services hurd)
26 #:use-module (gnu packages admin)
27 #:use-module (gnu packages hurd)
28 #:use-module (gnu services)
29 #:use-module (gnu services shepherd)
30 #:use-module (gnu system)
31 #:use-module (gnu system shadow)
32 #:use-module (guix gexp)
33 #:use-module (guix records)
34 #:export (hurd-console-configuration
35 hurd-console-service-type
36 hurd-getty-configuration
37 hurd-getty-service-type
38
39 hurd-login-configuration
40 hurd-login-service-type))
41
42;;;
43;;; The Hurd VGA console service.
44;;;
45
46(define-record-type* <hurd-console-configuration>
47 hurd-console-configuration make-hurd-console-configuration
48 hurd-console-configuration?
49 (hurd hurd-console-configuration-hurd ;file-like
50 (default hurd)))
51
52(define (hurd-console-shepherd-service config)
53 "Return a <shepherd-service> for a Hurd VGA console with CONFIG."
54
55 (define console-command
56 #~(list
57 (string-append #$(hurd-console-configuration-hurd config) "/bin/console")
58 "-c" "/dev/vcs"
59 "-d" "vga"
60 "-d" "pc_kbd"
61 "-d" "generic_speaker"))
62
63 (list (shepherd-service
64 (documentation "Run the Hurd’s VGA console client.")
65 (provision '(console))
66 (requirement '(user-processes))
67 (start #~(make-forkexec-constructor #$console-command))
68 (stop #~(make-kill-destructor)))))
69
70(define hurd-console-service-type
71 (service-type
72 (name 'console)
73 (description "Run the Hurd console client.")
74 (extensions
75 (list (service-extension shepherd-root-service-type
76 hurd-console-shepherd-service)))
77 (default-value (hurd-console-configuration))))
78
79
80;;;
81;;; The Hurd getty service.
82;;;
83
84(define-record-type* <hurd-getty-configuration>
85 hurd-getty-configuration make-hurd-getty-configuration
86 hurd-getty-configuration?
87 (hurd hurd-getty-configuration-hurd ;file-like
88 (default hurd))
89 (tty hurd-getty-configuration-tty) ;string
90 (baud-rate hurd-getty-configuration-baud-rate
91 (default 38400))) ;integer
92
93(define (hurd-getty-shepherd-service config)
94 "Return a <shepherd-service> for a Hurd getty with CONFIG."
95
96 (let ((hurd (hurd-getty-configuration-hurd config))
97 (tty (hurd-getty-configuration-tty config))
98 (baud-rate (hurd-getty-configuration-baud-rate config)))
99
100 (define getty-command
101 #~(list
102 (string-append #$hurd "/libexec/getty")
103 #$(number->string baud-rate)
104 #$tty))
105
106 (list
107 (shepherd-service
108 (documentation "Run getty on a tty.")
109 (provision (list (string->symbol (string-append "term-" tty))))
110 (requirement '(user-processes console))
111 (start #~(make-forkexec-constructor #$getty-command))
112 (stop #~(make-kill-destructor))))))
113
114(define hurd-getty-service-type
115 (service-type
116 (name 'getty)
117 (extensions (list (service-extension shepherd-root-service-type
118 hurd-getty-shepherd-service)))
119 (description
120 "Provide console login using the Hurd @command{getty} program.")))
121
122;;;
123;;; Hurd login service
124;;;
125
126(define-record-type* <hurd-login-configuration>
127 hurd-login-configuration make-hurd-login-configuration
128 hurd-login-configuration?
129 (hurd hurd-login-configuration-hurd ;file-like
130 (default hurd)))
131
132(define (hurd-login-accounts config)
133 (let ((hurd (hurd-login-configuration-hurd config)))
134 (list (user-group
135 (name "login")
136 (system? #t))
137 (user-account
138 (name "login")
139 (group "login")
140 (system? #t)
141 (comment "login user")
142 (home-directory "/etc/login")
143 (shell (file-append hurd "/bin/loginpr"))))))
144
145(define hurd-login-service-type
146 (service-type
147 (name 'login)
148 (extensions (list (service-extension account-service-type
149 hurd-login-accounts)))
150 (description
151 "Provide the login user for use by the Hurd @command{login} command.")
152 (default-value (hurd-login-configuration))))
153
154;;; hurd.scm ends here