gnu: installer: Launch the installer as kmscon login-program.

Source /etc/environment just before starting the installer. The login program
is supposed to load the environment variables of this file through PAM, but as
we replace it by the installer, they are no longer available. This is mostly
useful for the LANG environment variable.

* gnu/installer/build-installer.scm (installer-program-launcher): New exported
procedure.
* gnu/system/install.scm (%installation-services): Restore most of the origin
code. kmscon is only started on TTY1, and the graphical installer is the
login-program.
This commit is contained in:
Mathieu Othacehe 2018-11-23 23:18:59 +09:00 committed by Ludovic Courtès
parent 16006a05a1
commit a79617468e
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 144 additions and 103 deletions

View File

@ -37,7 +37,8 @@
#:use-module (gnu packages xorg) #:use-module (gnu packages xorg)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:export (installer-program)) #:export (installer-program
installer-program-launcher))
(define not-config? (define not-config?
;; Select (guix …) and (gnu …) modules, except (guix config). ;; Select (guix …) and (gnu …) modules, except (guix config).
@ -288,3 +289,34 @@ selected keymap."
#$(installer-exit installer))))) #$(installer-exit installer)))))
(program-file "installer" installer-builder)) (program-file "installer" installer-builder))
;; We want the installer to honor the LANG environment variable, so that the
;; locale is correctly installed when the installer is launched, and the
;; welcome page is possibly translated. The /etc/environment file (containing
;; LANG) is supposed to be loaded using PAM by the login program. As the
;; installer replaces the login program, read this file and set all the
;; variables it contains before starting the installer. This is a dirty hack,
;; we might want to find a better way to do it in the future.
(define (installer-program-launcher installer)
"Return a file-like object that set the variables in /etc/environment and
run the given INSTALLER."
(define load-environment
#~(call-with-input-file "/etc/environment"
(lambda (port)
(let ((lines (read-lines port)))
(map (lambda (line)
(match (string-split line #\=)
((name value)
(setenv name value))))
lines)))))
(define wrapper
(with-imported-modules '((gnu installer utils))
#~(begin
(use-modules (gnu installer utils)
(ice-9 match))
#$load-environment
(system #$(installer-program installer)))))
(program-file "installer-launcher" wrapper))

View File

@ -209,37 +209,43 @@ the user's target storage device rather than on the RAM disk."
(persistent? #f) (persistent? #f)
(max-database-size (* 5 (expt 2 20)))))) ;5 MiB (max-database-size (* 5 (expt 2 20)))))) ;5 MiB
(define %installation-services
;; List of services of the installation system.
(let ((motd (plain-file "motd" "
\x1b[1;37mWelcome to the installation of the Guix System Distribution!\x1b[0m
\x1b[2mThere is NO WARRANTY, to the extent permitted by law. In particular, you may
LOSE ALL YOUR DATA as a side effect of the installation process. Furthermore,
it is 'beta' software, so it may contain bugs.
You have been warned. Thanks for being so brave.\x1b[0m
")))
(define (normal-tty tty) (define (normal-tty tty)
(service kmscon-service-type (mingetty-service (mingetty-configuration (tty tty)
(kmscon-configuration (auto-login "root")
(virtual-terminal tty) (login-pause? #t))))
(auto-login "root"))))
(define bare-bones-os (define bare-bones-os
(load "examples/bare-bones.tmpl")) (load "examples/bare-bones.tmpl"))
(define %installation-services (list (service virtual-terminal-service-type)
;; List of services of the installation system.
(list (login-service (login-configuration
;; The motd is overlapped by the graphical installer,
;; so make sure it is not printed.
(motd #f)))
;; This will be the active virtual terminal at boot. The graphical
;; installer is launched as the 'shell' program of the root
;; user-account. Thanks to auto-login, it will be started
;; automatically. Another option would have been to set the graphical
;; installer as a login program. However, it is preferable to wait
;; for the login phase to be over, so that the environnment variables
;; of /etc/environment like LANG are loaded by PAM.
(normal-tty "tty1")
;; Documentation.
(service kmscon-service-type (service kmscon-service-type
(kmscon-configuration (kmscon-configuration
(virtual-terminal "tty2") (virtual-terminal "tty1")
(login-program (log-to-info)) (login-program (installer-program-launcher
(auto-login "guest"))) newt-installer))))
(login-service (login-configuration
(motd motd)))
;; Documentation. The manual is in UTF-8, but
;; 'console-font-service' sets up Unicode support and loads a font
;; with all the useful glyphs like em dash and quotation marks.
(mingetty-service (mingetty-configuration
(tty "tty2")
(auto-login "guest")
(login-program (log-to-info))))
;; Documentation add-on. ;; Documentation add-on.
%configuration-template-service %configuration-template-service
@ -268,6 +274,14 @@ the user's target storage device rather than on the RAM disk."
;; since it takes the installation directory as an argument. ;; since it takes the installation directory as an argument.
(cow-store-service) (cow-store-service)
;; Install Unicode support and a suitable font. Use a font that
;; doesn't have more than 256 glyphs so that we can use colors with
;; varying brightness levels (see note in setfont(8)).
(service console-font-service-type
(map (lambda (tty)
(cons tty "lat9u-16"))
'("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
;; To facilitate copy/paste. ;; To facilitate copy/paste.
(service gpm-service-type) (service gpm-service-type)
@ -316,7 +330,7 @@ the user's target storage device rather than on the RAM disk."
(list bare-bones-os (list bare-bones-os
glibc-utf8-locales glibc-utf8-locales
texinfo texinfo
(canonical-package guile-2.2))))) (canonical-package guile-2.2))))))
(define %issue (define %issue
;; Greeting. ;; Greeting.
@ -361,12 +375,7 @@ the user's target storage device rather than on the RAM disk."
%shared-memory-file-system %shared-memory-file-system
%immutable-store))) %immutable-store)))
(users (list (users (list (user-account
(user-account
(inherit %root-account)
;; Launch the graphical installer.
(shell (installer-program newt-installer)))
(user-account
(name "guest") (name "guest")
(group "users") (group "users")
(supplementary-groups '("wheel")) ; allow use of sudo (supplementary-groups '("wheel")) ; allow use of sudo