From 3ad3c55842dd34adc4b1a1b65ba0abfbdf5b92ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 17 Apr 2019 00:27:04 +0200 Subject: installer: Desktop environment page now includes window managers. * gnu/installer/services.scm ()[snippet]: Change to be a list of sexps and add default value. [packages]: New field. (%system-services): Adjust 'snippet' fields to be lists of sexps. Add Openbox, awesome, i3, and ratpoison. (system-services->configuration): Adjust 'snippet' handling. Honor 'packages' field. --- gnu/installer/services.scm | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'gnu/installer') diff --git a/gnu/installer/services.scm b/gnu/installer/services.scm index 4dbfe74bf9..6d9d65e8c5 100644 --- a/gnu/installer/services.scm +++ b/gnu/installer/services.scm @@ -20,7 +20,6 @@ (define-module (gnu installer services) #:use-module (guix records) #:use-module (srfi srfi-1) - #:use-module (ice-9 match) #:export (system-service? system-service-name system-service-type @@ -37,7 +36,10 @@ system-service? (name system-service-name) ;string (type system-service-type) ;'desktop | 'networking - (snippet system-service-snippet)) ;sexp + (snippet system-service-snippet ;list of sexps + (default '())) + (packages system-service-packages ;list of sexps + (default '()))) ;; This is the list of desktop environments supported as services. (define %system-services @@ -51,26 +53,38 @@ (list (desktop-environment (name "GNOME") - (snippet '(service gnome-desktop-service-type))) + (snippet '((service gnome-desktop-service-type)))) (desktop-environment (name "Xfce") - (snippet '(service xfce-desktop-service-type))) + (snippet '((service xfce-desktop-service-type)))) (desktop-environment (name "MATE") - (snippet '(service mate-desktop-service-type))) + (snippet '((service mate-desktop-service-type)))) (desktop-environment (name "Enlightenment") - (snippet '(service enlightenment-desktop-service-type))) + (snippet '((service enlightenment-desktop-service-type)))) + (desktop-environment + (name "Openbox") + (packages '((specification->package "openbox")))) + (desktop-environment + (name "awesome") + (packages '((specification->package "awesome")))) + (desktop-environment + (name "i3") + (packages '((specification->package "i3-wm")))) + (desktop-environment + (name "ratpoison") + (packages '((specification->package "ratpoison")))) ;; Networking. (system-service (name (G_ "OpenSSH secure shell daemon (sshd)")) (type 'networking) - (snippet '(service openssh-service-type))) + (snippet '((service openssh-service-type)))) (system-service (name (G_ "Tor anonymous network router")) (type 'networking) - (snippet '(service tor-service-type))) + (snippet '((service tor-service-type)))) ;; Network connectivity management. (system-service @@ -86,7 +100,7 @@ (system-service (name (G_ "DHCP client (dynamic IP address assignment)")) (type 'network-management) - (snippet '(service dhcp-client-service-type)))))) + (snippet '((service dhcp-client-service-type))))))) (define (desktop-system-service? service) "Return true if SERVICE is a desktop environment service." @@ -98,20 +112,21 @@ (define (system-services->configuration services) "Return the configuration field for SERVICES." - (let* ((snippets (append-map (lambda (service) - (match (system-service-snippet service) - ((and lst (('service _ ...) ...)) - lst) - (sexp - (list sexp)))) - services)) + (let* ((snippets (append-map system-service-snippet services)) + (packages (append-map system-service-packages services)) (desktop? (find desktop-system-service? services)) (base (if desktop? '%desktop-services '%base-services))) (if (null? snippets) - `((services ,base)) - `((services (append (list ,@snippets + `(,@(if (null? packages) + '() + `((packages (list ,@packages)))) + (services ,base)) + `(,@(if (null? packages) + '() + `((packages (list ,@packages)))) + (services (append (list ,@snippets ,@(if desktop? ;; XXX: Assume 'keyboard-layout' is in -- cgit v1.2.3 From 2d5867a213c4d23882e463d599eb236032086250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 17 Apr 2019 10:34:02 +0200 Subject: installer: Change language as soon as it has been chosen. Previously we'd call 'setlocale' only after the complete 'locale' step had finished. * gnu/installer/newt/locale.scm (run-language-page): Set the 'LANGUAGE' environment variable before returning. --- gnu/installer/newt/locale.scm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'gnu/installer') diff --git a/gnu/installer/newt/locale.scm b/gnu/installer/newt/locale.scm index b819d06691..01bcf76025 100644 --- a/gnu/installer/newt/locale.scm +++ b/gnu/installer/newt/locale.scm @@ -30,9 +30,9 @@ #:export (run-locale-page)) (define (run-language-page languages language->text) - (let ((title (G_ "Locale language"))) + (define result (run-listbox-selection-page - #:title title + #:title (G_ "Locale language") #:info-text (G_ "Choose the language to use for the \ installation process and for the installed system.") #:info-textbox-width 70 @@ -44,7 +44,13 @@ installation process and for the installed system.") (lambda _ (raise (condition - (&installer-step-abort))))))) + (&installer-step-abort)))))) + + ;; Immediately install the chosen language so that the territory page that + ;; comes after (optionally) is displayed in the chosen language. + (setenv "LANGUAGE" result) + + result) (define (run-territory-page territories territory->text) (let ((title (G_ "Locale location"))) -- cgit v1.2.3 From 7837a57241775fed221c9e03700af73263e222ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 17 Apr 2019 11:07:21 +0200 Subject: installer: Display language and territory names natively. * gnu/installer.scm (installer-program): Add calls to 'bindtextdomain'. * gnu/installer/newt/locale.scm (run-locale-page) : Add calls to 'gettext'. --- gnu/installer/newt/locale.scm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'gnu/installer') diff --git a/gnu/installer/newt/locale.scm b/gnu/installer/newt/locale.scm index 01bcf76025..7108e2960b 100644 --- a/gnu/installer/newt/locale.scm +++ b/gnu/installer/newt/locale.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Mathieu Othacehe +;;; Copyright © 2019 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -161,7 +162,13 @@ glibc locale string and return it." (run-language-page (sort-languages (delete-duplicates (map locale-language supported-locales))) - (cut language-code->language-name iso639-languages <>))))) + (lambda (language) + (let ((english (language-code->language-name iso639-languages + language))) + (setenv "LANGUAGE" language) + (let ((native (gettext english "iso_639-3"))) + (unsetenv "LANGUAGE") + native))))))) (installer-step (id 'territory) (compute @@ -175,10 +182,11 @@ glibc locale string and return it." ;; supported by the previously selected language. (run-territory-page (delete-duplicates (map locale-territory locales)) - (lambda (territory-code) - (if territory-code - (territory-code->territory-name iso3166-territories - territory-code) + (lambda (territory) + (if territory + (let ((english (territory-code->territory-name + iso3166-territories territory))) + (gettext english "iso_3166-1")) (G_ "No location")))))))) (installer-step (id 'codeset) -- cgit v1.2.3 From 7cb7be17af77caa084c1b5ebf20748dd04f208fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 17 Apr 2019 11:41:52 +0200 Subject: installer: Look up timezone name translations in "iso_3166-1". * gnu/installer/newt/timezone.scm (run-timezone-page): Add call to 'gettext' for timezone names. --- gnu/installer/newt/timezone.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gnu/installer') diff --git a/gnu/installer/newt/timezone.scm b/gnu/installer/newt/timezone.scm index 63b44af729..67bf41ff84 100644 --- a/gnu/installer/newt/timezone.scm +++ b/gnu/installer/newt/timezone.scm @@ -50,12 +50,15 @@ returned." (define (run-page timezone-tree) (define (loop path) + ;; XXX: Translation of time zones isn't perfect here because the + ;; "iso_3166-1" domain contains translation for "territories" (like + ;; "Antarctic") but not for continents (like "Africa"). (let ((timezones (locate-children timezone-tree path))) (run-listbox-selection-page #:title (G_ "Timezone") #:info-text (G_ "Please select a timezone.") #:listbox-items timezones - #:listbox-item->text identity + #:listbox-item->text (cut gettext <> "iso_3166-1") #:button-text (if (null? path) (G_ "Exit") (G_ "Back")) -- cgit v1.2.3 From 14755829dc268a3983036908750f4ea40c5224b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 17 Apr 2019 11:51:31 +0200 Subject: installer: Sort items with 'string-locale key). It that case, a list containing the selected items will be returned. If SORT-LISTBOX-ITEMS? is set to #t, the listbox items are sorted using -'string<=' procedure (after being converted to text). +'string-locale key is pressed, otherwise nothing will happen. @@ -249,7 +250,7 @@ ITEM was inserted into LISTBOX." items)) (define (sort-listbox-items listbox-items) - "Return LISTBOX-ITEMS sorted using the 'string<=' procedure on the text + "Return LISTBOX-ITEMS sorted using the 'string-localetext item))) @@ -258,7 +259,7 @@ corresponding to each item in the list." (sort items (lambda (a b) (let ((text-a (cdr a)) (text-b (cdr b))) - (string<= text-a text-b)))))) + (string-locale Date: Wed, 17 Apr 2019 15:11:21 +0200 Subject: installer: Translate keyboard layout names. * gnu/installer.scm (installer-program)[installer-builder]: Call 'bindtextdomain' for "xkeyboard-config". * gnu/installer/newt/keymap.scm (run-keymap-page): Add calls to 'gettext'. --- gnu/installer/newt/keymap.scm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'gnu/installer') diff --git a/gnu/installer/newt/keymap.scm b/gnu/installer/newt/keymap.scm index 948b54783c..623bfe079d 100644 --- a/gnu/installer/newt/keymap.scm +++ b/gnu/installer/newt/keymap.scm @@ -97,7 +97,8 @@ names of the selected keyboard layout and variant." (run-layout-page (sort-layouts layouts) (lambda (layout) - (x11-keymap-layout-description layout)))))) + (gettext (x11-keymap-layout-description layout) + "xkeyboard-config")))))) ;; Propose the user to select a variant among those supported by the ;; previously selected layout. (installer-step @@ -111,15 +112,16 @@ names of the selected keyboard layout and variant." (run-variant-page (sort-variants variants) (lambda (variant) - (x11-keymap-variant-description - variant)))))))))) + (gettext (x11-keymap-variant-description variant) + "xkeyboard-config")))))))))) (define (format-result result) (let ((layout (x11-keymap-layout-name (result-step result 'layout))) (variant (and=> (result-step result 'variant) (lambda (variant) - (x11-keymap-variant-name variant))))) + (gettext (x11-keymap-variant-name variant) + "xkeyboard-config"))))) (list layout (or variant "")))) (format-result (run-installer-steps #:steps keymap-steps))) -- cgit v1.2.3 From 818595a974a3fc9caa7edd8a4f19d5485c91caba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 17 Apr 2019 15:13:31 +0200 Subject: installer: Parse the 'shortDescription' field from xkeyboard-config. * gnu/installer/keymap.scm ()[synopsis]: New field. (xkb-rules->models+layouts): Fill out the 'synopsis' field. --- gnu/installer/keymap.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gnu/installer') diff --git a/gnu/installer/keymap.scm b/gnu/installer/keymap.scm index d66b376d9c..df9fc5e441 100644 --- a/gnu/installer/keymap.scm +++ b/gnu/installer/keymap.scm @@ -36,6 +36,7 @@ make-x11-keymap-layout x11-keymap-layout? x11-keymap-layout-name + x11-keymap-layout-synopsis x11-keymap-layout-description x11-keymap-layout-variants @@ -60,7 +61,8 @@ x11-keymap-layout make-x11-keymap-layout x11-keymap-layout? (name x11-keymap-layout-name) ;string - (description x11-keymap-layout-description) ;string + (synopsis x11-keymap-layout-synopsis) ;string (e.g., "en") + (description x11-keymap-layout-description) ;string (a whole phrase) (variants x11-keymap-layout-variants)) ;list of (define-record-type* @@ -117,6 +119,8 @@ Configuration Database, describing possible XKB configurations." (variantList ,[variant -> v] ...)) (x11-keymap-layout (name name) + (synopsis (car + (assoc-ref rest-layout 'shortDescription))) (description (car (assoc-ref rest-layout 'description))) (variants (list v ...)))] @@ -126,6 +130,8 @@ Configuration Database, describing possible XKB configurations." . ,rest-layout)) (x11-keymap-layout (name name) + (synopsis (car + (assoc-ref rest-layout 'shortDescription))) (description (car (assoc-ref rest-layout 'description))) (variants '()))])) -- cgit v1.2.3 From 9015e63996156dfaafecef182d20128f268c2719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 17 Apr 2019 15:16:08 +0200 Subject: installer: Sort keyboard layouts according to language and translations. Previously, we would always (1) put English first, and (2) sort the other layouts based on their English description. This fixes both issues. * gnu/installer/newt/keymap.scm (sort-layouts)[layoutconfiguration)) @@ -64,14 +65,29 @@ (define (sort-layouts layouts) "Sort LAYOUTS list by putting the US layout ahead and return it." + (define (layout <>))) + (lambda (main others) + (append (sort main layout Date: Sun, 21 Apr 2019 12:06:25 +0200 Subject: installer: Fix skip-to-step issue. When trying to jump to the first step, DONE-STEPS ends-up being null, which fails the matching condition. * gnu/installer/steps.scm (skip-to-step): Split matching conditions to handle the empty DONE-STEPS case properly. --- gnu/installer/steps.scm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'gnu/installer') diff --git a/gnu/installer/steps.scm b/gnu/installer/steps.scm index 1483cdc3db..039dd0ca10 100644 --- a/gnu/installer/steps.scm +++ b/gnu/installer/steps.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018 Mathieu Othacehe +;;; Copyright © 2018, 2019 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. ;;; @@ -113,16 +113,24 @@ return the accumalated result so far." (define* (skip-to-step step result #:key todo-steps done-steps) - (match (list todo-steps done-steps) - (((todo . rest-todo) (prev-done ... last-done)) - (if (eq? (installer-step-id todo) - (installer-step-id step)) + (match todo-steps + ((todo . rest-todo) + (let ((found? (eq? (installer-step-id todo) + (installer-step-id step)))) + (cond + (found? (run result #:todo-steps todo-steps - #:done-steps done-steps) - (skip-to-step step (pop-result result) - #:todo-steps (cons last-done todo-steps) - #:done-steps prev-done))))) + #:done-steps done-steps)) + ((and (not found?) + (null? done-steps)) + (error (format #f "Step ~a not found" (installer-step-id step)))) + (else + (match done-steps + ((prev-done ... last-done) + (skip-to-step step (pop-result result) + #:todo-steps (cons last-done todo-steps) + #:done-steps prev-done))))))))) (define* (run result #:key todo-steps done-steps) (match todo-steps -- cgit v1.2.3 From 7611074f677f1c3cfe5da426f387eeda1b6ad825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 23 Apr 2019 00:08:54 +0200 Subject: installer: Run 'guix system init' with the right locale. * gnu/installer/utils.scm (run-shell-command): Add #:locale and honor it. * gnu/installer/newt/final.scm (run-install-shell): Add 'locale' parameter; pass it to 'install-system'. (run-final-page): Obtain locale from RESULT; pass it to 'run-install-shell'. * gnu/installer/final.scm (install-system): Add 'locale' parameter; pass it to 'run-shell-command'. --- gnu/installer/final.scm | 8 +++++--- gnu/installer/newt/final.scm | 9 +++++---- gnu/installer/utils.scm | 14 +++++++++++++- 3 files changed, 23 insertions(+), 8 deletions(-) (limited to 'gnu/installer') diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm index e1c62f5ce0..07946f72c3 100644 --- a/gnu/installer/final.scm +++ b/gnu/installer/final.scm @@ -24,13 +24,15 @@ #:use-module (guix build utils) #:export (install-system)) -(define (install-system) +(define (install-system locale) "Start COW-STORE service on target directory and launch guix install command -in a subshell." +in a subshell. LOCALE must be the locale name under which that command will +run, or #f." (let ((install-command (format #f "guix system init ~a ~a" (%installer-configuration-file) (%installer-target-dir)))) (mkdir-p (%installer-target-dir)) (start-service 'cow-store (list (%installer-target-dir))) - (false-if-exception (run-shell-command install-command)))) + (false-if-exception (run-shell-command install-command + #:locale locale)))) diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm index 645c1e8689..f492c5dbb7 100644 --- a/gnu/installer/newt/final.scm +++ b/gnu/installer/newt/final.scm @@ -65,22 +65,23 @@ press the button to reboot."))) (G_ "The final system installation step failed. You can retry the \ last step, or restart the installer."))) -(define (run-install-shell) +(define (run-install-shell locale) (clear-screen) (newt-suspend) - (let ((install-ok? (install-system))) + (let ((install-ok? (install-system locale))) (newt-resume) install-ok?)) (define (run-final-page result prev-steps) - (let* ((configuration (format-configuration prev-steps result)) + (let* ((configuration (format-configuration prev-steps result)) (user-partitions (result-step result 'partition)) + (locale (result-step result 'locale)) (install-ok? (with-mounted-partitions user-partitions (configuration->file configuration) (run-config-display-page) - (run-install-shell)))) + (run-install-shell locale)))) (if install-ok? (run-install-success-page) (run-install-failed-page)))) diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm index e91f90a84d..256722729c 100644 --- a/gnu/installer/utils.scm +++ b/gnu/installer/utils.scm @@ -54,9 +54,21 @@ number. If no percentage is found, return #f" (and result (string->number (match:substring result 1))))) -(define (run-shell-command command) +(define* (run-shell-command command #:key locale) + "Run COMMAND, a string, with Bash, and in the given LOCALE." (call-with-temporary-output-file (lambda (file port) + (when locale + (let ((supported? (false-if-exception + (setlocale LC_ALL locale)))) + ;; If LOCALE is not supported, then set LANGUAGE, which might at + ;; least give us translated messages. + (if supported? + (format port "export LC_ALL=\"~a\"~%" locale) + (format port "export LANGUAGE=\"~a\"~%" + (string-take locale + (string-index locale #\_)))))) + (format port "~a~%" command) ;; (format port "exit~%") (close port) -- cgit v1.2.3