From ab3a64507a792e4da0527b423fbc28f8768e736a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Tue, 2 Aug 2016 18:05:23 +0200
Subject: [PATCH] system: Define 'GUIX_LOCPATH' to work around 'glibc' package
 defect.

Our 'glibc' package currently ignores /run/current-system/locale,
although the intent is to look for locales in that directory.

* gnu/packages/base.scm (glibc/linux): Add comment about
/run/current-system/locale being ignored.
* gnu/system.scm (operating-system-environment-variables): Add
'GUIX_LOCPATH'.
* gnu/tests/base.scm (run-basic-test): Add "locale" test.
---
 gnu/packages/base.scm |  1 +
 gnu/system.scm        |  7 ++++++-
 gnu/tests/base.scm    | 12 ++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 5edf3eb4931..a4768371028 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -535,6 +535,7 @@ (define-public glibc/linux
             ;;
             ;; `--localedir' is not honored, so work around it.
             ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
+            ;; FIXME: This hack no longer works on 2.23!
             (string-append "libc_cv_localedir=/run/current-system/locale/"
                            ,version)
 
diff --git a/gnu/system.scm b/gnu/system.scm
index 04dd7a845c2..d6bf6c413c3 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -545,7 +545,12 @@ (define (operating-system-environment-variables os)
 
     ;; By default, applications that use D-Bus, such as Emacs, abort at startup
     ;; when /etc/machine-id is missing.  Make sure these warnings are non-fatal.
-    ("DBUS_FATAL_WARNINGS" . "0")))
+    ("DBUS_FATAL_WARNINGS" . "0")
+
+    ;; XXX: Normally we wouldn't need to do this, but our glibc@2.23 package
+    ;; looks things up in 'PREFIX/lib/locale' instead of
+    ;; '/run/current-system/locale' as was intended.
+    ("GUIX_LOCPATH" . "/run/current-system/locale")))
 
 (define %setuid-programs
   ;; Default set of setuid-root programs.
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index a6278b25d4d..7170ab1e382 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -178,6 +178,18 @@ (define marionette
              '(false-if-exception (getaddrinfo "does-not-exist"))
              marionette))
 
+          (test-equal "locale"
+            "en_US.utf8"
+            (marionette-eval '(begin
+                                ;; XXX: This 'setenv' call wouldn't be needed
+                                ;; but our glibc@2.23 currently ignores
+                                ;; /run/current-system/locale.
+                                (setenv "GUIX_LOCPATH"
+                                        "/run/current-system/locale")
+                                (let ((before (setlocale LC_ALL "en_US.utf8")))
+                                  (setlocale LC_ALL before)))
+                             marionette))
+
           (test-assert "screendump"
             (begin
               (marionette-control (string-append "screendump " #$output
-- 
GitLab