dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 34e2119f7873d2f8d36dbeec30084f78f644bdb2
Author: John Darrington <[email protected]>
Date: Mon Feb 13 09:15:54 2017 +0100
installer: Infer likely entries for user accounts from the gecos field.
* gnu/system/installer/user-edit.scm (user-edit-page-init): Add a
callback expression to the form constructor.
---
gnu/system/installer/user-edit.scm | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/gnu/system/installer/user-edit.scm
b/gnu/system/installer/user-edit.scm
index 23c1587..7adf88a 100644
--- a/gnu/system/installer/user-edit.scm
+++ b/gnu/system/installer/user-edit.scm
@@ -129,8 +129,29 @@
(getmaxx (inner pr))
(getmaxy text-window) 0 #:panel #f))
- (form (make-form (my-fields))))
-
+ (form (make-form (my-fields)
+ (lambda (frm)
+ ;; Infer the most likely desired values of the
+ ;; name and home fields from the other field values
+ (let* ((f (get-current-field frm))
+ (fv (form-get-value frm (field-symbol f)))
+ (brk (string-index fv #\space))
+ (first
+ (and brk
+ (string-map char-downcase
+ (string-take fv brk)))))
+ (cond ((eq? (field-symbol f) 'comment)
+ (when first
+ (form-set-value! frm 'name first)
+ (form-set-value! frm 'home
+ (string-append
"/home/"
+
first))))
+ ((eq? (field-symbol f) 'name)
+ (form-set-value! frm 'home
+ (string-append
+ "/home/"
+ (form-get-value
+ frm 'name))))))))))
(page-set-datum! p 'navigation nav)
(let ((acc (page-datum p 'account)))