me
/
guix
Archived
1
0
Fork 0

installer: User accounts can now have a "real name."

* gnu/installer/newt/user.scm (run-user-add-page): Add #:real-name.  Add
a label and entry for the real name and initialize the 'real-name' field
of the <user> record.
* gnu/installer/final.scm (create-user-database): Set the 'comment'
field of the <user-account> record.
master
Ludovic Courtès 2019-04-28 22:28:51 +02:00
parent 43c1c44a11
commit 0e8e963d73
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 28 additions and 11 deletions

View File

@ -71,6 +71,7 @@ USERS."
(string=? "root" (user-name user))) (string=? "root" (user-name user)))
(sys:user-account (name (user-name user)) (sys:user-account (name (user-name user))
(comment (user-real-name user))
(group "users") (group "users")
(uid (if root? 0 #f)) (uid (if root? 0 #f))
(home-directory (home-directory

View File

@ -29,14 +29,17 @@
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
#:export (run-user-page)) #:export (run-user-page))
(define* (run-user-add-page #:key (name "") (home-directory "")) (define* (run-user-add-page #:key (name "") (real-name "")
"Run a form to enter the user name, home directory, and password. Use NAME (home-directory ""))
and HOME-DIRECTORY as the initial values in the form." "Run a form to enter the user name, home directory, and password. Use NAME,
REAL-NAME, and HOME-DIRECTORY as the initial values in the form."
(define (pad-label label) (define (pad-label label)
(string-pad-right label 20)) (string-pad-right label 20))
(let* ((label-name (let* ((label-name
(make-label -1 -1 (pad-label (G_ "Name")))) (make-label -1 -1 (pad-label (G_ "Name"))))
(label-real-name
(make-label -1 -1 (pad-label (G_ "Real name"))))
(label-home-directory (label-home-directory
(make-label -1 -1 (pad-label (G_ "Home directory")))) (make-label -1 -1 (pad-label (G_ "Home directory"))))
(label-password (label-password
@ -44,11 +47,13 @@ and HOME-DIRECTORY as the initial values in the form."
(entry-width 30) (entry-width 30)
(entry-name (make-entry -1 -1 entry-width (entry-name (make-entry -1 -1 entry-width
#:initial-value name)) #:initial-value name))
(entry-real-name (make-entry -1 -1 entry-width
#:initial-value real-name))
(entry-home-directory (make-entry -1 -1 entry-width (entry-home-directory (make-entry -1 -1 entry-width
#:initial-value home-directory)) #:initial-value home-directory))
(entry-password (make-entry -1 -1 entry-width (entry-password (make-entry -1 -1 entry-width
#:flags FLAG-PASSWORD)) #:flags FLAG-PASSWORD))
(entry-grid (make-grid 3 4)) (entry-grid (make-grid 2 5))
(button-grid (make-grid 1 1)) (button-grid (make-grid 1 1))
(ok-button (make-button -1 -1 (G_ "OK"))) (ok-button (make-button -1 -1 (G_ "OK")))
(grid (make-grid 1 2)) (grid (make-grid 1 2))
@ -59,10 +64,12 @@ and HOME-DIRECTORY as the initial values in the form."
(set-entry-grid-field 0 0 label-name) (set-entry-grid-field 0 0 label-name)
(set-entry-grid-field 1 0 entry-name) (set-entry-grid-field 1 0 entry-name)
(set-entry-grid-field 0 1 label-home-directory) (set-entry-grid-field 0 1 label-real-name)
(set-entry-grid-field 1 1 entry-home-directory) (set-entry-grid-field 1 1 entry-real-name)
(set-entry-grid-field 0 2 label-password) (set-entry-grid-field 0 2 label-home-directory)
(set-entry-grid-field 1 2 entry-password) (set-entry-grid-field 1 2 entry-home-directory)
(set-entry-grid-field 0 3 label-password)
(set-entry-grid-field 1 3 entry-password)
(set-grid-field button-grid 0 0 GRID-ELEMENT-COMPONENT ok-button) (set-grid-field button-grid 0 0 GRID-ELEMENT-COMPONENT ok-button)
@ -70,11 +77,17 @@ and HOME-DIRECTORY as the initial values in the form."
entry-name entry-name
(lambda (component) (lambda (component)
(set-entry-text entry-home-directory (set-entry-text entry-home-directory
(string-append "/home/" (entry-value entry-name))))) (string-append "/home/" (entry-value entry-name)))
(when (string-null? (entry-value entry-real-name))
(set-entry-text entry-real-name
(string-titlecase (entry-value entry-name))))))
(add-components-to-form form (add-components-to-form form
label-name label-home-directory label-password label-name label-real-name
entry-name entry-home-directory entry-password label-home-directory label-password
entry-name entry-real-name
entry-home-directory entry-password
ok-button) ok-button)
(make-wrapped-grid-window (vertically-stacked-grid (make-wrapped-grid-window (vertically-stacked-grid
@ -94,6 +107,7 @@ and HOME-DIRECTORY as the initial values in the form."
(cond (cond
((components=? argument ok-button) ((components=? argument ok-button)
(let ((name (entry-value entry-name)) (let ((name (entry-value entry-name))
(real-name (entry-value entry-real-name))
(home-directory (entry-value entry-home-directory)) (home-directory (entry-value entry-home-directory))
(password (entry-value entry-password))) (password (entry-value entry-password)))
(if (or (string=? name "") (if (or (string=? name "")
@ -103,12 +117,14 @@ and HOME-DIRECTORY as the initial values in the form."
(run-user-add-page)) (run-user-add-page))
(user (user
(name name) (name name)
(real-name real-name)
(home-directory home-directory) (home-directory home-directory)
(password (password
(confirm-password password (confirm-password password
(lambda () (lambda ()
(run-user-add-page (run-user-add-page
#:name name #:name name
#:real-name real-name
#:home-directory #:home-directory
home-directory))))))))))) home-directory)))))))))))
(lambda () (lambda ()