Subject: [PATCH 4/4] system: Use locale information in grub.cfg.

From: Miguel <[email-masked]>
Date: Fri, 26 Apr 2019 12:51:23 +0200

system: Use locale information in grub.cfg.

* gnu/bootloader/grub.scm (module-declaration): Add (gnu system locale).
(locale-config-entries): New procedure.
(grub-configuration-file): Use locale-config-entries.
---
 gnu/bootloader/grub.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
From 216f818bb27d3c491681c4d67e483279c3065b2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
 <[email-masked]>
Date: Fri, 26 Apr 2019 11:58:43 +0200
Subject: [PATCH 4/4] system: Use locale information in grub.cfg.

* gnu/bootloader/grub.scm (module-declaration): Add (gnu system locale).
(locale-config-entries): New procedure.
(grub-configuration-file): Use locale-config-entries.
---
 gnu/bootloader/grub.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 446f90157c..92c33063c3 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016 Chris Marusich <[email-masked]>
 ;;; Copyright © 2017 Leo Famulari <[email-masked]>
 ;;; Copyright © 2017 Mathieu Othacehe <[email-masked]>
+;;; Copyright © 2019 Miguel Ángel Arruga Vivas <[email-masked]>
 ;;;
 ;;; 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,27 @@ fi~%"
                  #$(theme-colors grub-theme-color-normal)
                  #$(theme-colors grub-theme-color-highlight))))
 
+(define* (locale-config-entries config 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."
+  (define grub (bootloader-package
+                (bootloader-configuration-bootloader config)))
+  (define (locale-dir)
+    #~(let ((dir #$grub:locale))
+        dir))
+  (define (lang-id)
+    (let ((definition (locale-name->definition locale)))
+      (locale-definition-source definition)))
+
+  (and locale
+       (member "locale" (package-outputs grub))
+       #~(format #$port "
+# Configure GRUB with the selected locale.
+set locale_dir=~a
+set lang=~a~%"
+                 #$(strip-mount-point store-mount-point (locale-dir))
+                 #$(lang-id))))
+
 
 ;;;
 ;;; Configuration file.
@@ -364,6 +387,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-mount-point (first all-entries))
+                           #:locale locale #:port #~port))
 
   (define builder
     #~(call-with-output-file #$output
@@ -374,6 +401,7 @@ keymap ~a~%" keymap)))))
 ")
           #$sugar
           #$keyboard-layout-config
+          #$locale-config
           (format port "
 set default=~a
 set timeout=~a~%"
-- 
2.21.0