From 762b00327be7a21ac3e04b10610666b0d323104b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?= Date: Tue, 23 Apr 2019 15:03:58 +0200 Subject: [PATCH 3/3] system: Use locale information in grub.cfg. * gnu/bootloader/grub.scm (locale-config-entries): New procedure. (grub-configuration-file): Use locale-config-entries. --- gnu/bootloader/grub.scm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 446f90157c..81c4e31e28 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2017 Leo Famulari ;;; Copyright © 2017 Mathieu Othacehe +;;; Copyright © 2019 Miguel Ángel Arruga Vivas ;;; ;;; This file is part of GNU Guix. ;;; @@ -28,6 +29,7 @@ #:use-module (gnu system uuid) #:use-module (gnu system file-systems) #:use-module (gnu system keyboard) + #:use-module (gnu system locale) #:autoload (gnu packages bootloaders) (grub) #:autoload (gnu packages gtk) (guile-cairo guile-rsvg) #:autoload (gnu packages xorg) (xkeyboard-config) @@ -216,6 +218,36 @@ fi~%" #$(theme-colors grub-theme-color-normal) #$(theme-colors grub-theme-color-highlight)))) +(define* (locale-config-entries config store-device store-mount-point + #:key locale port) + "Return a gexp that writes to PORT (a port-valued gexp) the +'grub.cfg' part concerned with locale configuration." + ;; FIXME: /boot in a separate partition is not suported. The prefix must + ;; be removed in order to make it work. GRUB EFI installation contains an + ;; usable /boot/efi/grub/locale/ folder too, but it is not used, for the + ;; same reason. + (define grub-locale-dir "/boot/grub/locale") + (define (grub-lang-id) + (let ((definition (locale-name->definition locale))) + (locale-definition-source definition))) + (define (grub-locale-file) + (string-append grub-locale-dir "/" (grub-lang-id) ".mo")) + + (and locale + #~(format #$port "# Configure GRUB with the selected locale. + +# Set the root for the locale file +~a + +if [ -d ~a ]; then + set locale_dir=~a + set lang=~a +fi~%" + #$(grub-root-search store-device (grub-locale-file)) + #$grub-locale-dir + #$grub-locale-dir + #$(grub-lang-id)))) + ;;; ;;; Configuration file. @@ -364,6 +396,10 @@ entries corresponding to old generations of the system." terminal_input at_keyboard insmod keylayouts keymap ~a~%" keymap))))) + (define locale-config + (locale-config-entries config (menu-entry-device (first all-entries)) + (menu-entry-device-mount-point (first all-entries)) + #:locale locale #:port #~port)) (define builder #~(call-with-output-file #$output @@ -374,6 +410,7 @@ keymap ~a~%" keymap))))) ") #$sugar #$keyboard-layout-config + #$locale-config (format port " set default=~a set timeout=~a~%" -- 2.21.0