From 126d4c12ce18a35a0d971778133f05b7c6ad81b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 12 Apr 2019 14:15:59 +0200 Subject: install: Add standalone documentation service. * gnu/system/install.scm (log-to-info): Add 'tty' and 'user' parameters. Open the tty and change UIDs/GIDs. (documentation-shepherd-service): New procedure. (%documentation-users, documentation-service-type): New variables. (%installation-services): Use it instead of 'mingetty-service'. --- gnu/system/install.scm | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/gnu/system/install.scm b/gnu/system/install.scm index 91e7b481e8..71a9c2f19b 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -73,11 +73,24 @@ ;;; Code: -(define (log-to-info) +;;; +;;; Documentation service. +;;; + +(define (log-to-info tty user) "Return a script that spawns the Info reader on the right section of the manual." (program-file "log-to-info" - #~(begin + #~(let ((tty (open-file #$(string-append "/dev/" tty) + "r0+"))) + (redirect-port tty (current-output-port)) + (redirect-port tty (current-error-port)) + (redirect-port tty (current-input-port)) + + (let ((pw (getpwnam #$user))) + (setgid (passwd:gid pw)) + (setuid (passwd:uid pw))) + ;; 'gunzip' is needed to decompress the doc. (setenv "PATH" (string-append #$gzip "/bin")) @@ -86,6 +99,33 @@ manual." "-f" (string-append #$guix "/share/info/guix.info") "-n" "System Installation")))) +(define (documentation-shepherd-service tty) + (list (shepherd-service + (provision (list (symbol-append 'term- (string->symbol tty)))) + (requirement '(user-processes host-name udev virtual-terminal)) + + (start #~(make-forkexec-constructor + (list #$(log-to-info tty "documentation")))) + (stop #~(make-kill-destructor))))) + +(define %documentation-users + ;; User account for the Info viewer. + (list (user-account (name "documentation") + (system? #t) + (group "nogroup") + (home-directory "/var/empty")))) + +(define documentation-service-type + ;; Documentation viewer service. + (service-type (name 'documentation) + (extensions + (list (service-extension shepherd-root-service-type + documentation-shepherd-service) + (service-extension account-service-type + (const %documentation-users)))) + (description "Run the Info reader on a tty."))) + + (define %backing-directory ;; Sub-directory used as the backing store for copy-on-write. "/tmp/guix-inst") @@ -239,10 +279,7 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m ;; 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)))) + (service documentation-service-type "tty2") ;; Documentation add-on. %configuration-template-service -- cgit v1.2.3