services: mingetty-service: Use <mingetty-configuration> objects.

* gnu/services/base.scm (<mingetty-configuration>): New record type.
  (mingetty-service): Expect a single <mingetty-configuration> instead
  of keyword arguments.
  (%base-services): Adjust accordingly.
* gnu/system/install.scm (installation-services): Likewise.
* doc/guix.texi (Base Services): Adjust accordingly.
This commit is contained in:
Ludovic Courtès 2015-09-12 13:53:21 +02:00
parent be1c2c54d9
commit 66e4f01c60
3 changed files with 117 additions and 83 deletions

View File

@ -5753,25 +5753,44 @@ this:
Return a service that sets the host name to @var{name}. Return a service that sets the host name to @var{name}.
@end deffn @end deffn
@deffn {Scheme Procedure} mingetty-service @var{tty} [#:motd] @ @deffn {Scheme Procedure} mingetty-service @var{config}
[#:auto-login #f] [#:login-program] [#:login-pause? #f] @ Return a service to run mingetty according to @var{config}, a
[#:allow-empty-passwords? #f] @code{<mingetty-configuration>} object, which specifies the tty to run, among
Return a service to run mingetty on @var{tty}. other things.
When @var{allow-empty-passwords?} is true, allow empty log-in password. When
@var{auto-login} is true, it must be a user name under which to log-in
automatically. @var{login-pause?} can be set to @code{#t} in conjunction with
@var{auto-login}, in which case the user will have to press a key before the
login shell is launched.
When true, @var{login-program} is a gexp denoting the name
of the log-in program (the default is the @code{login} program from the Shadow
tool suite.)
@var{motd} is a monadic value containing a text file to use as
the ``message of the day''.
@end deffn @end deffn
@deftp {Data Type} mingetty-configuration
This is the data type representing the configuration of Mingetty, which
implements console log-in.
@table @asis
@item @code{tty}
The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
@item @code{motd}
A file-like object containing the ``message of the day''.
@item @code{auto-login} (default: @code{#f})
When true, this field must be a string denoting the user name under
which the the system automatically logs in. When it is @code{#f}, a
user name and password must be entered to log in.
@item @code{login-program} (default: @code{#f})
This must be either @code{#f}, in which case the default log-in program
is used (@command{login} from the Shadow tool suite), or a gexp denoting
the name of the log-in program.
@item @code{login-pause?} (default: @code{#f})
When set to @code{#t} in conjunction with @var{auto-login}, the user
will have to press a key before the log-in shell is launched.
@item @code{mingetty} (default: @var{mingetty})
The Mingetty package to use.
@end table
@end deftp
@cindex name service cache daemon @cindex name service cache daemon
@cindex nscd @cindex nscd
@deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @ @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @

View File

@ -50,6 +50,9 @@
console-keymap-service console-keymap-service
console-font-service console-font-service
udev-service udev-service
mingetty-configuration
mingetty-configuration?
mingetty-service mingetty-service
%nscd-default-caches %nscd-default-caches
@ -342,60 +345,63 @@ stopped before 'kill' is called."
(stop #~(const #t)) (stop #~(const #t))
(respawn? #f)))) (respawn? #f))))
(define* (mingetty-service tty (define-record-type* <mingetty-configuration>
#:key mingetty-configuration make-mingetty-configuration
(motd (plain-file "motd" "Welcome.\n")) mingetty-configuration?
auto-login (mingetty mingetty-configuration-mingetty ;<package>
login-program (default mingetty))
login-pause? (tty mingetty-configuration-tty) ;string
(motd mingetty-configuration-motd ;file-like
(default (plain-file "motd" "Welcome.\n")))
(auto-login mingetty-auto-login ;string | #f
(default #f))
(login-program mingetty-login-program ;gexp
(default #f))
(login-pause? mingetty-login-pause? ;Boolean
(default #f))
;; Allow empty passwords by default so that ;; Allow empty passwords by default so that first-time users can log in when
;; first-time users can log in when the 'root' ;; the 'root' account has just been created.
;; account has just been created. (allow-empty-passwords? mingetty-configuration-allow-empty-passwords?
(allow-empty-passwords? #t)) (default #t))) ;Boolean
"Return a service to run mingetty on @var{tty}.
When @var{allow-empty-passwords?} is true, allow empty log-in password. When (define* (mingetty-service config)
@var{auto-login} is true, it must be a user name under which to log-in "Return a service to run mingetty according to @var{config}, a
automatically. @var{login-pause?} can be set to @code{#t} in conjunction with @code{<mingetty-configuration>} object, which specifies the tty to run, among
@var{auto-login}, in which case the user will have to press a key before the other things."
login shell is launched. (match config
(($ <mingetty-configuration> mingetty tty motd auto-login login-program
login-pause? allow-empty-passwords?)
(service
(documentation "Run mingetty on an tty.")
(provision (list (symbol-append 'term- (string->symbol tty))))
When true, @var{login-program} is a gexp denoting the name ;; Since the login prompt shows the host name, wait for the 'host-name'
of the log-in program (the default is the @code{login} program from the Shadow ;; service to be done. Also wait for udev essentially so that the tty
tool suite.) ;; text is not lost in the middle of kernel messages (XXX).
(requirement '(user-processes host-name udev))
@var{motd} is a file-like object to use as the ``message of the day''." (start #~(make-forkexec-constructor
(service (list (string-append #$mingetty "/sbin/mingetty")
(documentation (string-append "Run mingetty on " tty ".")) "--noclear" #$tty
(provision (list (symbol-append 'term- (string->symbol tty)))) #$@(if auto-login
#~("--autologin" #$auto-login)
#~())
#$@(if login-program
#~("--loginprog" #$login-program)
#~())
#$@(if login-pause?
#~("--loginpause")
#~()))))
(stop #~(make-kill-destructor))
;; Since the login prompt shows the host name, wait for the 'host-name' (pam-services
;; service to be done. Also wait for udev essentially so that the tty ;; Let 'login' be known to PAM. All the mingetty services will have
;; text is not lost in the middle of kernel messages (XXX). ;; that PAM service, but that's fine because they're all identical and
(requirement '(user-processes host-name udev)) ;; duplicates are removed.
(list (unix-pam-service "login"
(start #~(make-forkexec-constructor #:allow-empty-passwords? allow-empty-passwords?
(list (string-append #$mingetty "/sbin/mingetty") #:motd motd)))))))
"--noclear" #$tty
#$@(if auto-login
#~("--autologin" #$auto-login)
#~())
#$@(if login-program
#~("--loginprog" #$login-program)
#~())
#$@(if login-pause?
#~("--loginpause")
#~()))))
(stop #~(make-kill-destructor))
(pam-services
;; Let 'login' be known to PAM. All the mingetty services will have
;; that PAM service, but that's fine because they're all identical and
;; duplicates are removed.
(list (unix-pam-service "login"
#:allow-empty-passwords? allow-empty-passwords?
#:motd motd)))))
(define-record-type* <nscd-configuration> nscd-configuration (define-record-type* <nscd-configuration> nscd-configuration
make-nscd-configuration make-nscd-configuration
@ -841,12 +847,19 @@ This is the GNU operating system, welcome!\n\n")))
(console-font-service "tty5") (console-font-service "tty5")
(console-font-service "tty6") (console-font-service "tty6")
(mingetty-service "tty1" #:motd motd) (mingetty-service (mingetty-configuration
(mingetty-service "tty2" #:motd motd) (tty "tty1") (motd motd)))
(mingetty-service "tty3" #:motd motd) (mingetty-service (mingetty-configuration
(mingetty-service "tty4" #:motd motd) (tty "tty2") (motd motd)))
(mingetty-service "tty5" #:motd motd) (mingetty-service (mingetty-configuration
(mingetty-service "tty6" #:motd motd) (tty "tty3") (motd motd)))
(mingetty-service (mingetty-configuration
(tty "tty4") (motd motd)))
(mingetty-service (mingetty-configuration
(tty "tty5") (motd motd)))
(mingetty-service (mingetty-configuration
(tty "tty6") (motd motd)))
(static-networking-service "lo" "127.0.0.1" (static-networking-service "lo" "127.0.0.1"
#:provision '(loopback)) #:provision '(loopback))
(syslog-service) (syslog-service)

View File

@ -242,22 +242,24 @@ it is alpha software, so it may BREAK IN UNEXPECTED WAYS.
You have been warned. Thanks for being so brave. You have been warned. Thanks for being so brave.
"))) ")))
(define (normal-tty tty) (define (normal-tty tty)
(mingetty-service tty (mingetty-service (mingetty-configuration (tty tty)
#:motd motd (motd motd)
#:auto-login "root" (auto-login "root")
#:login-pause? #t)) (login-pause? #t))))
(list (mingetty-service "tty1" (list (mingetty-service (mingetty-configuration
#:motd motd (tty "tty1")
#:auto-login "root") (motd motd)
(auto-login "root")))
;; Documentation. The manual is in UTF-8, but ;; Documentation. The manual is in UTF-8, but
;; 'console-font-service' sets up Unicode support and loads a font ;; 'console-font-service' sets up Unicode support and loads a font
;; with all the useful glyphs like em dash and quotation marks. ;; with all the useful glyphs like em dash and quotation marks.
(mingetty-service "tty2" (mingetty-service (mingetty-configuration
#:motd motd (tty "tty2")
#:auto-login "guest" (motd motd)
#:login-program (log-to-info)) (auto-login "guest")
(login-program (log-to-info))))
;; Documentation add-on. ;; Documentation add-on.
(configuration-template-service) (configuration-template-service)