mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 22:08:16 -05:00
services: agetty: Add agetty instance to base services. Make its tty optional.
* gnu/services/base.scm (%base-services): Instantiate agetty-service. (default-serial-port): New variable. (agetty-shepherd-service): Make tty optional, default to the above. * doc/guix.texi (agetty-configuration): Update "tty" documentation. * gnu/system/install.scm (agetty-default-service): Delete variable. (embedded-installation-os): Remove agetty-default-service instance. Add "console" kernel-argument.
This commit is contained in:
parent
2b870303e7
commit
5a9902c8ac
3 changed files with 79 additions and 27 deletions
|
@ -9724,7 +9724,20 @@ man page for more information.
|
||||||
|
|
||||||
@item @code{tty}
|
@item @code{tty}
|
||||||
The name of the console this agetty runs on, as a string---e.g.,
|
The name of the console this agetty runs on, as a string---e.g.,
|
||||||
@code{"ttyS0"}. This argument is mandatory.
|
@code{"ttyS0"}. This argument is optional, it will default to
|
||||||
|
a reasonable default serial port used by the kernel Linux.
|
||||||
|
|
||||||
|
For this, if there is a value for an option @code{agetty.tty} in the kernel
|
||||||
|
command line, agetty will extract the device name of the serial port
|
||||||
|
from it and use that.
|
||||||
|
|
||||||
|
If not and if there is a value for an option @code{console} with a tty in
|
||||||
|
the Linux command line, agetty will extract the device name of the
|
||||||
|
serial port from it and use that.
|
||||||
|
|
||||||
|
In both cases, agetty will leave the other serial device settings
|
||||||
|
(baud rate etc.) alone---in the hope that Linux pinned them to the
|
||||||
|
correct values.
|
||||||
|
|
||||||
@item @code{baud-rate} (default: @code{#f})
|
@item @code{baud-rate} (default: @code{#f})
|
||||||
A string containing a comma-separated list of one or more baud rates, in
|
A string containing a comma-separated list of one or more baud rates, in
|
||||||
|
|
|
@ -817,7 +817,7 @@ (define-record-type* <agetty-configuration>
|
||||||
agetty-configuration?
|
agetty-configuration?
|
||||||
(agetty agetty-configuration-agetty ;<package>
|
(agetty agetty-configuration-agetty ;<package>
|
||||||
(default util-linux))
|
(default util-linux))
|
||||||
(tty agetty-configuration-tty) ;string
|
(tty agetty-configuration-tty) ;string | #f
|
||||||
(term agetty-term ;string | #f
|
(term agetty-term ;string | #f
|
||||||
(default #f))
|
(default #f))
|
||||||
(baud-rate agetty-baud-rate ;string | #f
|
(baud-rate agetty-baud-rate ;string | #f
|
||||||
|
@ -890,6 +890,40 @@ (define-record-type* <agetty-configuration>
|
||||||
;;; (default #f))
|
;;; (default #f))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(define (default-serial-port)
|
||||||
|
"Return a gexp that determines a reasonable default serial port
|
||||||
|
to use as the tty. This is primarily useful for headless systems."
|
||||||
|
#~(begin
|
||||||
|
;; console=device,options
|
||||||
|
;; device: can be tty0, ttyS0, lp0, ttyUSB0 (serial).
|
||||||
|
;; options: BBBBPNF. P n|o|e, N number of bits,
|
||||||
|
;; F flow control (r RTS)
|
||||||
|
(let* ((not-comma (char-set-complement (char-set #\,)))
|
||||||
|
(command (linux-command-line))
|
||||||
|
(agetty-specs (find-long-options "agetty.tty" command))
|
||||||
|
(console-specs (filter (lambda (spec)
|
||||||
|
(and (string-prefix? "tty" spec)
|
||||||
|
(not (or
|
||||||
|
(string-prefix? "tty0" spec)
|
||||||
|
(string-prefix? "tty1" spec)
|
||||||
|
(string-prefix? "tty2" spec)
|
||||||
|
(string-prefix? "tty3" spec)
|
||||||
|
(string-prefix? "tty4" spec)
|
||||||
|
(string-prefix? "tty5" spec)
|
||||||
|
(string-prefix? "tty6" spec)
|
||||||
|
(string-prefix? "tty7" spec)
|
||||||
|
(string-prefix? "tty8" spec)
|
||||||
|
(string-prefix? "tty9" spec)))))
|
||||||
|
(find-long-options "console" command)))
|
||||||
|
(specs (append agetty-specs console-specs)))
|
||||||
|
(match specs
|
||||||
|
(() #f)
|
||||||
|
((spec _ ...)
|
||||||
|
;; Extract device name from first spec.
|
||||||
|
(match (string-tokenize spec not-comma)
|
||||||
|
((device-name _ ...)
|
||||||
|
device-name)))))))
|
||||||
|
|
||||||
(define agetty-shepherd-service
|
(define agetty-shepherd-service
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <agetty-configuration> agetty tty term baud-rate auto-login
|
(($ <agetty-configuration> agetty tty term baud-rate auto-login
|
||||||
|
@ -900,8 +934,9 @@ (define agetty-shepherd-service
|
||||||
erase-characters kill-characters chdir delay nice extra-options)
|
erase-characters kill-characters chdir delay nice extra-options)
|
||||||
(list
|
(list
|
||||||
(shepherd-service
|
(shepherd-service
|
||||||
|
(modules '((ice-9 match) (gnu build linux-boot)))
|
||||||
(documentation "Run agetty on a tty.")
|
(documentation "Run agetty on a tty.")
|
||||||
(provision (list (symbol-append 'term- (string->symbol tty))))
|
(provision (list (symbol-append 'term- (string->symbol (or tty "auto")))))
|
||||||
|
|
||||||
;; Since the login prompt shows the host name, wait for the 'host-name'
|
;; Since the login prompt shows the host name, wait for the 'host-name'
|
||||||
;; service to be done. Also wait for udev essentially so that the tty
|
;; service to be done. Also wait for udev essentially so that the tty
|
||||||
|
@ -946,6 +981,9 @@ (define agetty-shepherd-service
|
||||||
('always "--local-line=always")
|
('always "--local-line=always")
|
||||||
('never "-local-line=never")))
|
('never "-local-line=never")))
|
||||||
#~())
|
#~())
|
||||||
|
#$@(if tty
|
||||||
|
#~()
|
||||||
|
#~("--keep-baud"))
|
||||||
#$@(if extract-baud?
|
#$@(if extract-baud?
|
||||||
#~("--extract-baud")
|
#~("--extract-baud")
|
||||||
#~())
|
#~())
|
||||||
|
@ -1009,7 +1047,7 @@ (define agetty-shepherd-service
|
||||||
#$@(if login-pause?
|
#$@(if login-pause?
|
||||||
#~("--login-pause")
|
#~("--login-pause")
|
||||||
#~())
|
#~())
|
||||||
#$tty
|
#$(or tty (default-serial-port))
|
||||||
#$@(if baud-rate
|
#$@(if baud-rate
|
||||||
#~(#$baud-rate)
|
#~(#$baud-rate)
|
||||||
#~())
|
#~())
|
||||||
|
@ -1058,18 +1096,21 @@ (define mingetty-shepherd-service
|
||||||
;; text is not lost in the middle of kernel messages (XXX).
|
;; text is not lost in the middle of kernel messages (XXX).
|
||||||
(requirement '(user-processes host-name udev))
|
(requirement '(user-processes host-name udev))
|
||||||
|
|
||||||
(start #~(make-forkexec-constructor
|
(start #~(let ((tty #$(default-serial-port)))
|
||||||
(list #$(file-append mingetty "/sbin/mingetty")
|
(if tty
|
||||||
"--noclear" #$tty
|
(make-forkexec-constructor
|
||||||
#$@(if auto-login
|
(list #$(file-append mingetty "/sbin/mingetty")
|
||||||
#~("--autologin" #$auto-login)
|
"--noclear" #$tty
|
||||||
#~())
|
#$@(if auto-login
|
||||||
#$@(if login-program
|
#~("--autologin" #$auto-login)
|
||||||
#~("--loginprog" #$login-program)
|
#~())
|
||||||
#~())
|
#$@(if login-program
|
||||||
#$@(if login-pause?
|
#~("--loginprog" #$login-program)
|
||||||
#~("--loginpause")
|
#~())
|
||||||
#~()))))
|
#$@(if login-pause?
|
||||||
|
#~("--loginpause")
|
||||||
|
#~())))
|
||||||
|
(const #f)))) ; never start.
|
||||||
(stop #~(make-kill-destructor)))))))
|
(stop #~(make-kill-destructor)))))))
|
||||||
|
|
||||||
(define mingetty-service-type
|
(define mingetty-service-type
|
||||||
|
@ -2012,6 +2053,11 @@ (define %base-services
|
||||||
(cons tty %default-console-font))
|
(cons tty %default-console-font))
|
||||||
'("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
|
'("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
|
||||||
|
|
||||||
|
(agetty-service (agetty-configuration
|
||||||
|
(extra-options '("-L")) ; no carrier detect
|
||||||
|
(term "vt100")
|
||||||
|
(tty #f))) ; automatic
|
||||||
|
|
||||||
(mingetty-service (mingetty-configuration
|
(mingetty-service (mingetty-configuration
|
||||||
(tty "tty1")))
|
(tty "tty1")))
|
||||||
(mingetty-service (mingetty-configuration
|
(mingetty-service (mingetty-configuration
|
||||||
|
|
|
@ -381,14 +381,6 @@ (define installation-os
|
||||||
nvi ;:wq!
|
nvi ;:wq!
|
||||||
%base-packages))))
|
%base-packages))))
|
||||||
|
|
||||||
(define* (agetty-default-service #:optional (tty "ttyS0"))
|
|
||||||
"Return an agetty-service on the given TTY"
|
|
||||||
(agetty-service (agetty-configuration
|
|
||||||
(extra-options '("-L"))
|
|
||||||
(baud-rate "115200")
|
|
||||||
(term "vt100")
|
|
||||||
(tty tty))))
|
|
||||||
|
|
||||||
(define* (embedded-installation-os bootloader bootloader-target tty
|
(define* (embedded-installation-os bootloader bootloader-target tty
|
||||||
#:key (extra-modules '()))
|
#:key (extra-modules '()))
|
||||||
"Return an installation os for embedded systems.
|
"Return an installation os for embedded systems.
|
||||||
|
@ -401,12 +393,13 @@ (define* (embedded-installation-os bootloader bootloader-target tty
|
||||||
(bootloader bootloader)
|
(bootloader bootloader)
|
||||||
(target bootloader-target)))
|
(target bootloader-target)))
|
||||||
(kernel linux-libre)
|
(kernel linux-libre)
|
||||||
|
(kernel-arguments
|
||||||
|
(cons (string-append "console=" tty)
|
||||||
|
(operating-system-user-kernel-arguments installation-os)))
|
||||||
(initrd (lambda (fs . rest)
|
(initrd (lambda (fs . rest)
|
||||||
(apply base-initrd fs
|
(apply base-initrd fs
|
||||||
#:extra-modules extra-modules
|
#:extra-modules extra-modules
|
||||||
rest)))
|
rest)))))
|
||||||
(services (cons* (agetty-default-service tty)
|
|
||||||
(operating-system-user-services installation-os)))))
|
|
||||||
|
|
||||||
(define beaglebone-black-installation-os
|
(define beaglebone-black-installation-os
|
||||||
(embedded-installation-os u-boot-beaglebone-black-bootloader
|
(embedded-installation-os u-boot-beaglebone-black-bootloader
|
||||||
|
|
Loading…
Reference in a new issue